|
|
|
|
|
by photochemsyn
1313 days ago
|
|
Nice article. On this bit: " It's about how you would write a regex package from scratch, in a language like C that doesn't already have regexes." There's a 30-line C regex matching program that Rob Pike wrote and Brian Kernighan wrote about here. It only implements . ^ $ * (where c is any literal): "A Regular Expression Matcher" (2007) https://www.cs.princeton.edu/courses/archive/spr09/cos333/be... > "Rob's implementation itself is a superb example of beautiful code: compact, elegant, efficient, and useful. It's one of the best examples of recursion that I have ever seen, and it shows the power of C pointers. Although at the time we were most interested in conveying the important role of a good notation in making a program easier to use and perhaps easier to write as well, the regular expression code has also been an excellent way to illustrate algorithms, data structures, testing, performance enhancement, and other important topics." - Brian Kernighan |
|