• OpenStars@startrek.website
    link
    fedilink
    English
    arrow-up
    1
    ·
    7 months ago

    I strongly hesitated saying anything at all b/c there are so very many different rules governing the behavior of every single kind of symbol. Though one jumping off point is the use of the parenthesis, without slashes prior to them and them meaning alternatives within a grouping context rather than merely “remembering”, for the sake of e.g. replacement or copying, so e.g. in the Unix CLI “grep” command this would not work even with the -e parameter (I am not so sure about perl-style though, or rather, this would work within pure perl, but perl-style regexps from within grep is another matter, plus that option itself is not universal across all forms of Unix).

    In any case, I hoped that the YoMama joke would be universally understood and appreciated regardless, across all of the many & varied language barriers 😜.

    • ChubakPDP11+TakeWithGrainOfSalt@programming.devOP
      link
      fedilink
      arrow-up
      1
      arrow-down
      1
      ·
      7 months ago

      True, but see, all these build up on the theoretical regex. The theoretical regex indeed has only 3 operators: dot for concatenation, pipe for alteration and the ‘kleene star’ [re: Sipser’s]. These 3 operators can express a finite state automata. You don’t really need all that other operators. Read this: https://swtch.com/~rsc/regexp/regexp1.html Algorithms like Thompson construction can translate a regex to a non-deterministic automata quite quickly, and then from there you can make a DFA or just simulate the NFA.

      I would not call PCRE ‘regular expression’ really. If you read the article I gave you it explains why they are mostly a practical utility than a theoretical groundwork. The regex in use today is far from the regex one learns about in books.

      I think regex is abused. People use it to parse context-free grammars. Extremely intricate and feature-rich patterns cause people to make mistakes, and end up with security holes!

      That being said, I really enjoy NeoVim’s regex. I also like Perl’s. But I would not rely on them for parsing, or even lexing.