4 ms·
Backreferences are certainly an extension. They are the primary reason that regular expression engines that allow them are slow.
by milesrout 10y ago
Backreferences are certainly an extension. They are the primary reason that regular expression engines that allow them are slow.
- tyingq 10y agoAhhh, "extension" meaning not in the POSIX basic definition. Sure. Though I don't know many tools that implement REs in that basic form. They almost all include features outside that definition.
- burntsushi 10y agoNo, extension as in it is not regular. Nothing to do with POSIX. RE2, Go and Rust do not provide backreference support in exchange for predictable performance.
- deleted 10y ago[deleted]
- deleted 10y ago[deleted]
- deleted 10y ago[deleted]
- notriddle 10y agoThere are plenty of regex engines that are guaranteed O(n) for all regexes they accept. There's re2, go-regex, and rust-regex just to list a few popular ones. They still use Perl-like syntax, and might still be able to parse non-regular languages, but you don't need to worry about users deliberately crafting regexes to eat up CPU time like PCRE.