A Regular Expression Matcher (2007)
cs.princeton.edu
cs.princeton.edu
2013: https://news.ycombinator.com/item?id=5672875
2011: https://news.ycombinator.com/item?id=2723366
Maybe others?
p.s. these links are just for curious readers; reposts are ok after a year or so—see https://news.ycombinator.com/newsfaq.html.
https://www.amazon.com/Beautiful-Code-Leading-Programmers-Pr...
We seem to have something of an Eternal September of regex implementation knowledge (abetted by Russ Cox's amazingly selective bibliography in his posts introducing RE2).
Here’s the repo if anyone is interested in checking out the others:
int matchstar(int c, char *regexp, char *text)
{
do { /* a * matches zero or more instances */
if (matchhere(regexp, text))
return 1;
} while (*text != '\0' && (*text++ == c || c == '.'));
return 0;
}
That can be used to match short strings, but not to grep through a filesystem. A good regex matcher has runtime O(N*M) where N is the length of the regex (typically very short) and M is the length of the scanned text.But now all I see there is something more akin to a demonstration of ice carving with chainsaws than something that should be used in a production system.
It's quite possible you might turn someone competent into a gibbering wreck (they are asking me to implement RE2 or Hyperscan in an hour!) :-)