liveBook · Manning

Regular expression

As explained in Vibe Engineering

A regular expression is a pattern notation for matching and extracting text according to specified character and sequence rules.

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

How Vibe Engineering covers it

How deep it goes
Explains backtracking and nested quantifiers with timings, then stops short of a complete regular-expression syntax tutorial.
Examples
Uses bold-delimiter patterns, adversarial asterisk strings, medicine dosage fields, notebook output, and missed extraction cases.
What it assumes
Assumes familiarity with text fields and generated code, while teaching the relevant backtracking failure mode from concrete patterns.
What you can do after
Diagnose regex performance risks and evaluate extraction quality with linting, timing tests, coverage counts, and record inspection.
How it connects
Connects regular expressions to static analysis, SAST, ReDoS, feature engineering, data preprocessing, and validation.

Also explained in

Compare how 32 books explain regular expression →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Vibe Engineering. The section links point to the parts of the book it draws on.