I’m imagining as years go by when/if this AI regex code breaks - nobody knows how it works or how to fix it. Am I wrong?

I’m not a programmer and I write shitty code but I can manage to write simple regex to create quick and dirty code. That’s a terrible programming choice I know but I never share my code. It’s just for me and it works.

  • Speaker [e/em/eir]@hexbear.net
    link
    fedilink
    English
    arrow-up
    18
    arrow-down
    2
    ·
    11 days ago

    Imagine still using regexes in current year. Every language has a parser combinator library, now, just write a damn parser and stop pretending you remember what a regular language is or that the garbage text you’re processing is a sentence in one.

    • anarchrist@lemmy.dbzer0.com
      link
      fedilink
      English
      arrow-up
      15
      ·
      11 days ago

      I’m the sicko doing regex find and replace in notepad++

      Looking forward to being able to start a consulting firm when my arcane knowledge is worth a premium

      • Speaker [e/em/eir]@hexbear.net
        link
        fedilink
        English
        arrow-up
        7
        ·
        11 days ago

        Should add treesitter to your toolbox. Never mind regex-replace when you can exploit the syntax of the actual programming language to do rich query-replace actions. 🌞

        • anarchrist@lemmy.dbzer0.com
          link
          fedilink
          English
          arrow-up
          5
          ·
          11 days ago

          That’s neat! I mostly use regex for like columns of text data. I think most people use excel but I hates it. Nasty little microsofts

      • Speaker [e/em/eir]@hexbear.net
        link
        fedilink
        English
        arrow-up
        8
        ·
        11 days ago

        Read this for a very light introduction to the concept, then type “parser combinator library <your language of choice>” into a search engine and never maintain a regular expression again!

          • Speaker [e/em/eir]@hexbear.net
            link
            fedilink
            English
            arrow-up
            2
            ·
            11 days ago

            Some implementations don’t support backtracking at all, but ones that do will have combinators like

            atomic parserA <|> atomic parserB <|> parserC
            -- equivalent to
            choice [parserA, parserB, parserC]
            

            where atomic and choice are parsers that take other parsers as arguments like and and or in the article, though the advice is to avoid backtracking whenever possible since it’s quite expensive. The little examples in the post are just a taste to make the idea legible, but not really suited for especially interesting parsers.

    • glans [it/its]@hexbear.net
      link
      fedilink
      English
      arrow-up
      3
      ·
      11 days ago

      I use regex because I don’t know what is a parser combinator library or how to acesss one. Why would i learn how to write a parser when I have a perfectly adequate, portable, thoroughly documented tool available?