Hasty Briefsbeta

Bilingual

Regular expression speed and error rates

14 hours ago
  • Regex for ICD-10 codes: [A-TV-Z][0-9][0-9AB]\.?[0-9A-TV-Z]{0,4} excludes U as first letter but allows it later.
  • Speed: Regex search (egrep) took 18 ms on an 800 KB file, while list search (grep) took 386 seconds—five orders of magnitude faster.
  • Error rates: Initially zero false negatives, but later 3 codes (U070, U071, U099) became false negatives due to standard changes; regex is more future-proof than an exhaustive list.
  • False positive rate depends on context: low in medical notes but extremely high in random alphanumeric text (99.9986% of matches are false).
  • The optional period may appear even without following alphanumeric characters, though not in the standard—practical usage can vary.