4 ms·
"There is no such thing as an unmaintainable/illegible basic regex..." To someone who knows BRE. I am one of those people. It's ERE and PCRE I do not underst
by ised 11y ago
"There is no such thing as an unmaintainable/illegible basic regex..."
To someone who knows BRE. I am one of those people. It's ERE and PCRE I do not understand very well.
Sharing solutions to common problems using BRE on HN always seems to trigger (unwarranted) criticism using either of the exact words you mention, or synonyms for them. "Unmaintainable" (by who?). "Illegible" (to who?).
I "maintain" 100's of BRE scripts. They are perfecty legible to me. None of them are so complex I cannot re-write them in a short time. It is the structure of the input that is complex and which takes time to recall.
I also use lex, a common utility found on almost all UNIX derived OS; this article seems to ignore that option. I like to think it's faster than Perl or Python, but I cannot say for sure.
- kevin_thibedeau 11y ago> I like to think it's faster than Perl or Python, but I cannot say for sure. It is. I implemented an assembly language parser with pyparsing. It worked okay but the function call overhead with a combinator-based parser handling both the lexing and grammar was murder. I replaced it with regexes and got a 6x speedup. Not something I would do with a complex grammar though. Native code would obviously blow this away in speed but it is fast enough now.
- bro-stick 11y agoPCRE JIT http://pcre.org/current/doc/html/pcre2jit.html http://pcre.org/current/doc/html/pcre2jit.html