4 ms·
This was actually going to be my solution as well. Regex engines are optimised for exactly this sort of problem, why duplicate the work manually?
by qntm 15y ago
This was actually going to be my solution as well. Regex engines are optimised for exactly this sort of problem, why duplicate the work manually?
- saucetenuto 15y agorfumani gave one reason: it won't produce the right answer. Here's another: your regex engine will probably fall over dead if you ask it apply a million-word alternation.
- eru 15y agogrep could be fine. I wouldn't trust backtracking regex engines, though.