Two Problems: Regular Expressions for Revolutionaries
summary
Regular expressions predate computers and are mathematically equivalent to finite-state machines, so they have no stack and therefore can't parse HTML reliably; JavaScript’s regex engine borrows Perl features like lookaheads that push it beyond pure regular languages. Examples: subway turnstiles modeled as states, a Lego Turing machine demonstration, and the implementation note to prefer the RegExp constructor for dynamic patterns. Conclusion: use regexes for shallow pattern matching, switch to grammars or parsers when nested structure matters.
AI-written summary · about
chapters (13)
- 0:00Introduction
- 1:11Why regular expressions can be problematic
- 3:52Whitespace in JavaScript
- 7:05Origins and basics of regular expressions
- 8:35Regex in Chomsky hierarchy
- 10:57Turing machines and regex
- 12:46Finite-state automata
- 13:52Why HTML cannot be parsed with regular expressions
- 15:16Perl's regex influence
- 17:09Regex strengths and limits
- 18:43Human language parsing
- 19:03Declaring regular expressions in JavaScript
- 19:55Regex applications and future
related talks
17mWhen Chomsky Met JavaScript: Exploring the Linguistics(...)
01h 13m/ Reg (exp) {2} lained / Demystifying Regular Expressions
01h 06mEverybody stands back! I know regular expressions
05mRegular expressions my secret love
26mAll Aboard the Regular Express
25mFormal Verification for JavaScript Regular Expressions: A Proven Mechanized Semantics(…)
24mSolving String Constraints with Regex-Dependent Functions through Transducers wi
23mLinear Matching of JavaScript Regular Expressions
