Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

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).



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.)


I 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.


A 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.


I'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.




Consider applying for YC's Fall 2025 batch! Applications are open till Aug 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: