4 ms·
But isn't that a crime of premature optimisation? Perl's integration of Regex makes them easy to use and they fit naturally in the language, a lot more than in
by Renaud 13y ago
But isn't that a crime of premature optimisation?
Perl's integration of Regex makes them easy to use and they fit naturally in the language, a lot more than in most implementations.
Being able to use Regex easily is a plus in my book.
Yes they are lower than some dedicated string search or some state machine ad-hoc implementation, but you can document Regexes and they pack a lot of punch.
If a Regex is causing a concern in term of performance, then it may be time to review that code and optimise it, otherwise why even bother?
When people talk about Regex being bad and they say you can often use string manipulation instead they only talk about the most trivial uses of Regex.
As soon as you go beyond that, using a Regex is almost always going to be cleaner than spewing lines of codes and building state machines to achieve the same functionality.
- maxerickson 13y agoIt's more a matter of different design taste than it is an optimization. (I don't think it is controversial that Python has a relatively simple language definition/grammar/etc; regex as language syntax would expand all of that quite a bit)