A regular expression matches or extracts text through character and sequence rules, but its compactness can conceal runtime and data-quality risks. Treat each pattern as executable logic: inspect its behavior, test difficult inputs, and verify the extracted results. section 8.2.2 section 4.4
Use regular expressions with explicit checks:
- Prefer patterns whose repetition structure is easy to reason about; a lazy wildcard between literal delimiters avoids the nested-quantifier problem described here. section 8.2.2
- Run security-oriented linting or SAST to flag potentially exponential patterns such as a repeated group containing another repetition. section 8.2.2
- Measure extraction coverage and inspect misses instead of accepting a high aggregate rate as proof of correctness. section 4.4
Safe-looking extraction can still fail
A dosage parser extracted values for 223,054 of 253,973 products, about 88%. Yet a record containing “5mg” produced missing dosage fields, showing why representative records and edge cases must supplement summary statistics. section 4.4
warning: Regular expression has exponential time complexity (no-unsafe-regex)
Use the warning as a compact review prompt for identifying regular expressions with potentially exponential time complexity. section 8.2.2































