4 ms·
"more memory and more overhead than e.g. splitting a string by simply scanning it." Regexes are simply scanning strings, they're just a more condensed syntax f
by benniw 12y ago
"more memory and more overhead than e.g. splitting a string by simply scanning it."
Regexes are simply scanning strings, they're just a more condensed syntax for specifying how the scanning should be done.
And in interpreted languages, using the built-in regex feature (which can apply high-level optimizations) will virtually always give much better performance than implementing the same logic by manually looping over the string character-by-character with the language's interpreted for/while loops.