4
ullebe1
3y

My biggest pet peeve is that too many developers don't realize that "regex != regular expressions", probably because of bad naming and bad documentation. It's easy to assume that they're the same, but most regex syntaxes today are actually at least context-free grammars, since they support backreferences.

Comments
  • 3
    regex is magic, that's all I know
  • 2
    @N00bPancakes I think that is a great way of seeing it. They certainly feel that way far too often!
  • 1
    Wait what? Regex is literally a short version of the phrase "regular expression". IMO, the statement is void of logic.
  • 3
    @iiii Regex and regular expressions might have been the same thing in the beginning, but as features like backreferences got added regex grew beyond simply being regular expressions. A "real" regular expression is a strictly defined computer science concept, even if many programmers refer to regex instead when they say "regular expression". This confusion for example brought down parts of Cloudflare some time ago. IIRC it was caused by something expecting a real regular expression, which all run in linear time and thus quite fast, but instead a regex that was much slower than that was used.
  • 1
    @iiii see http://nikic.github.io/2012/06/... for a more thorough explanation of the difference.
  • 1
    @ullebe1 regular expressions in computer science are equivalent to "regex" (the reason was stated before).

    Your argument is not an argument but a flawed logic of intermixing different domains. When programmers use the term "regular expression" they mean it in programner sense and not as something "regular" from a language theory standpoint.

    In a nutshell you're trying to be a snob, but fail at that.
  • 2
    Lots of misunderstanding here, lots of dick swinging too.

    Regular expressions were originally meant to parse regular languages as per the Chomsky hierarchy. Of course, PCRE and Ecmascript extensions have allowed them to parse context-free languages as well to a certain extent, but only superficially.

    There was never any claim that regular expressions themselves were regular languages.

    Kind of a weird thing to have as a "biggest pet peeve", but also @iiii isn't exactly correct here either.

    So yes, when people say "regular expressions", they DO mean it in a "regular language" sense, even if they don't know it. They added backreferences for certain trivial cases, not meant to parse context-free stuff. That's why you don't see parsers written in regex, but instead using LALR/RD parsers and the like (which ARE meant to parse context-free and context-sensitive languages).

    It's like saying "when people talk about cryptocurrency they aren't talking about cryptography". Of course they are.
Add Comment