I've seen people here made comments like "regex is too slow!", or "why would you do something so simple using regex!" (and then present a 10+ lines alternative instead), etc.
I haven't really used regex in industrial setting, so I'm curious if there are applications where regex is demonstratably just too slow, AND where a simple non-regex alternative exists that performs significantly (maybe even asymptotically!) better.
Obviously many highly-specialized string manipulations with sophisticated string algorithms will outperform regex easily, but I'm talking about cases where a simple solution exists and significantly outperforms regex.
What counts as simple is subjective, of course, but I think a reasonable standard is that if it uses only String
, StringBuilder
, etc, then it's probably simple.
Note: I would very much appreciate answers that demonstrate the following:
- a beginner-level regex solution to a non-toy real-life problem that performs horribly
- the simple non-regex solution
- the expert-level regex rewrite that performs comparably