3 ms·
Regex is not only powerful, it's also expensive. If you can solve a problem without regex, it's usually the better way to do it.
by coretx 4y ago
Regex is not only powerful, it's also expensive.
If you can solve a problem without regex, it's usually the better way to do it.
- mirker 4y agoIt’s very efficient in processing strings since it’s linear time with respect to input string length if implemented properly.
- klyrs 4y agoWhat do you mean "expensive"? When I've seen people roll their own state machines to replace a moderately-complex regex, the result is frequently hundreds of bug-ridden lines and rarely matches the performance of a decent regex engine. This laborious learning experience often results in reverting to the regex. It's the ignorance that's expensive.
- hayley-patton 4y agoDepends on your regex engine, and your non-regex solution. My engine (shameless self-plug https://github.com/telekons/one-more-re-nightmare https://github.com/telekons/one-more-re-nightmare) rivals hand-written automata, having to load each character more-or-less* only once, and throws in vectorisation for simple search loops too. I would not want to write or maintain the generated code.
- paulrpotts 4y agoBonus points for the King Crimson reference!