3 ms·
The title is a little misleading - perhaps better would be "A very limited subset of Regular Expressions in 100 lines of Scala". While the code is concise, thi
by bshimmin 12y ago
The title is a little misleading - perhaps better would be "A very limited subset of Regular Expressions in 100 lines of Scala".
While the code is concise, this is more a case of "it implements A and B of an X" than "it implements an X, apart from A and B".
Still, all three parts of the series are a good read, and definitely helpful for learning about parsing and about Scala.
- peq 12y agoRegular expressions just need 3 things: sequence, alternatives (|), and repetition(*). Everything else is an extension.
- brudgers 12y agoMathematically, regular expressions are limited in comparison to what are commonly called 'regular expressions' or 'regexes' by programmers. Mathematical regular expressions can be translated into automata, 'Regex style regular expressions' often cannot. The advantage of mathematical regular expressions is that they terminate in O(n) time based on the length of the input string. The disadvantage is that they lack features like capture groups and look ahead/behind. The important point is that engines like those of Perl or Java are not based on regular expressions in a mathematical sense. This is true of any Regex engine that stores state or backtracks.