4 ms·
Regex syntax is fairly gross, I agree. That being said I'd be surprised to your open-coded version of simple regexes like /hatstand.*teakettle/ or /badgerbrush
by glangdale 9y ago
Regex syntax is fairly gross, I agree.
That being said I'd be surprised to your open-coded version of simple regexes like /hatstand.*teakettle/ or /badgerbrush\s{12}/ was clearer than the regex, and it would almost certainly be dismally slow relative to a tuned regex implementation - unless you wrote a lot of one-off SIMD code.
Further, if given a bunch of different regexes to match simultaneously, your code would have to run them one by one.
Finally, quite frequently our customers/users are in a situation where they don't know what the regex is going to be, and they aren't going to let people inject arbitrary code into their applications.
- ohyes 9y agoA lot of the grossness is syntactic sugar, if one were so inclined they could get by with a handful of operators, and end up with something fairly clear as you demonstrated. So if anything I blame lack of good taste for regular expressions bad rep.