3 ms·
I wonder if this would be a good test to give a software developer candidate. Develop a regex matcher that matches a subset of the regex rules in your language
by jonny_eh 14y ago
I wonder if this would be a good test to give a software developer candidate. Develop a regex matcher that matches a subset of the regex rules in your language of choice (without using regex abilities, of course).
- dreen 14y agoI don't know, regexes have a lot of rules so you need to supply a reference, requiring them to remember it is overkill, not to mention some of those rules are pretty arcane.
- barrkel 14y agoA simple implementation of ?, +, * , [] and non-capturing, precedence-only () hardly needs a reference. Whether greedy vs non-greedy + / * are implemented doesn't really matter. I will say that the problem is much easier if you have a good grounding in the basics of compilers, while that knowledge is not hugely useful very often. Any positive value as a test will come from correlation with interest in CS IMO.
- jemfinch 14y agoI've asked it as an interview question many times; it works really well. The only bad part is that most candidates can't even write a correct strstr(3), so it becomes incredibly depressing.
- abecedarius 14y agohttps://github.com/darius/ung/blob/master/c/regexpoid.c https://github.com/darius/ung/blob/master/c/regexpoid.c was my solution; it handles a slightly more useful subset (including escaping) and saves some code by calling segment_matches at the top level. (I'd seen Pike's code years before in _The Practice of Programming_, so it's not independent.)