Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
Regular expression engine in 14 lines of Python (lisp.org)
4 points by 13ren on Sept 13, 2008 | hide | past | favorite | 1 comment



Not exactly an engine. You have to do the parsing yourself. A simple parser would do, but it's not trivial, and would very likely at least double the size. It's also probably far from efficient. Some of the core functionality is there, though.

I started to write a quick parser for it to post here, but I have to get going... Letters, numbers, etc. can just be passed as char(c) literals, star and plus modify the most recent thing appended to the list, (a|b|c) groupings recursively call the parser and wrap the result. The whole thing gets wrapped in nested-pair seq calls, e.g. seq(a, seq(b, seq(c))) like in box-and-pair notation.




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: