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

Same here, but I prefer Lua to Perl, and Lua's LPEG (http://www.inf.puc-rio.br/~roberto/lpeg/lpeg.html) compares very favorably to common regexp implementations. (There are benchmarks in the paper.)

It's based on PEGs, a different formalism than regular expressions. PEGs are more expressive - they're able to handle balanced, recursive structures, for example. LPEG is a nice middle ground between regular expressions and a full LALR(1) parser.



I'm not sure if "middle ground" is quite right; PEGs and CFGs can express a different set of languages, and each has their own advantages. Probably the most important tradeoff is that with PEGs you gain infinite lookahead and negation, but you lose left recursion and the ability to express ambiguity.


I meant "middle ground" in a practical sense, rather than the linguistic one - REs are good for simple string hackery, but not sufficient for nested structures. Using an actual parser generator (the yacc clone in your language of choice) can really be overkill for simple things, though. LPEG is a bit more expressive than just REs, but still easy to casually drop in during quick scripting.




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

Search: