4 ms·
Having worked in an industry where the linear vs. exponential performance implications of regular expressions and PCREs was crucial (intrusion protection system
by colanderman 5y ago
Having worked in an industry where the linear vs. exponential performance implications of regular expressions and PCREs was crucial (intrusion protection systems), I'd just as soon software professionals stop being sloppy with terminology.
Not to mention the plethora of mostly-but-not-totally compatible regexp languages which exist. C++ supports 6 [1], and that doesn't even include PCREs. Miscommunication about which language one is actually using is a common source of regexp bugs.
[1] https://en.cppreference.com/w/cpp/regex/syntax_option_type https://en.cppreference.com/w/cpp/regex/syntax_option_type
- earleybird 5y agoYes, thank you. If you're sloppy with words you probably have other nasty habits. (apologies to Heinlein) There are reasons to employ regular languages with extensions (to not quite context free languages) but be clear about what you're talking about.
- bawolff 5y agoI'd argue that if this is sloppy, then the use of "you" instead of "thou" is sloppy too. Using "you" for everything is confusing. How can i possibly know if you mean plural or singular? Sure some people might say "thou" is archaic, however so is using "regex" outside of academic contexts to mean regular languages. I don't see how one could justify one but not the other.
- efitz 5y agoGrammar sticklers usually fail on this point: human languages are not static, stuck in place from the time the stickler learned the rules. The current state of a human language is defined by common usage. The purpose of a language is for people to be able to communicate ideas. Ideas exist all up and down a specificity spectrum, e.g. “regex” might mean a specific syntax or one of several syntaxes depending on context. Kind of like “kleenex” might refer to a specific brand or to the general concept of tissue. If 99.9% of people successfully (by their own measure, not yours) communicate what they mean when they use the term “regular expression”, but you are among the 0.1% for which that interaction fails, then I would argue that the problem is your pedantry, not the term. I’m not saying this to be mean; I have similar issues.
- skissane 5y ago> C++ supports 6 Wow, TIL. I always thought C++ had evolved into an excessively complex language, but this really seems to take the cake. ECMAScript (with C++-only changes), basic POSIX, extended POSIX, POSIX awk, POSIX grep, and POSIX extended grep. You are right there is no PCRE in there, yet. (There's always C++23... and if not that, C++26 or C++30) (Although ECMASCript regex was heavily inspired by Perl/PCRE anyway, albeit without being 100% compatible with either, so in a sense PCRE is already there.)
- leni536 5y agoIt's unlikely that std::regex will gain new dialects. Unfortunately it is very broken, it's unlikely that a proposal to extend it would go through.
- MauranKilom 5y agoCan you elaborate (or point me to sources about) how std::regex is broken? I'd like to learn more.
- leni536 5y agoAFAIK it's not even the interface that is broken, but some standard libraries poushed out slow implementations that cannot be changed without an ABI break.
- tomcam 5y agoI tried to imagine the test suite for these C++ variations but failed due to a coronary event
- lloeki 5y ago> Having worked in an industry where the linear vs. exponential performance implications of regular expressions and PCREs was crucial (intrusion protection systems) same boat. that's why we use re2 in a way inspired by Go (which means losing a few features but the tradeoff is worth it): > The regexp implementation provided by this package is guaranteed to run in time linear in the size of the input. (This is a property not guaranteed by most open source implementations of regular expressions.) For more information about this property, see > https://swtch.com/~rsc/regexp/regexp1.html https://swtch.com/~rsc/regexp/regexp1.html > or any book about automata theory. https://pkg.go.dev/regexp https://pkg.go.dev/regexp
- colanderman 5y agoOCaml's regexps run in linear time also. They're based on Ville Laurikari's Tagged REs: https://laurikari.net/tre/ https://laurikari.net/tre/