Hover Text:

Wait, forgot to escape a space. Wheeeeee[taptaptap]eeeeee!

Transcript

[in a yellow box:]
Whenever I learn a new skill I concoct elaborate fantasy scenarios where it lets me save the day.

Megan: Oh no! The killer must have followed her on vacation!
[Megan points to computer.]
Megan: But to find them we’d have to search through 200 MB of emails looking for something formatted like an address!
Cueball: It’s hopeless!

Off-panel voice: Everybody stand back.

Off-panel voice: I know regular expressions.

[A man swings in on a rope, toward the computer.]

tap tap
The word PERL! appears in a bubble.

[The man swings away, and the other characters cheer.]

  • otacon239@feddit.de
    link
    fedilink
    arrow-up
    33
    ·
    10 months ago

    I learned regex in a data entry job when receiving spreadsheets of user info they entered themselves. The number of times I went from a 40-minute by-hand solution to a 30-second one was astounding.

    Need to clean up capitalization? Regex.

    Need to fix all the phone numbers with dashes in them? Regex.

    Need to make sure all the emails are valid? Regex.

    So many hours of tedium saved. It really is one of the most powerful tools to have in your back pocket.

        • elvith@feddit.de
          link
          fedilink
          arrow-up
          16
          ·
          10 months ago

          Who’s gonna tell them? I’d do it but I’m still busy parsing HTML with regex… it’s working any minute now!

          • otacon239@feddit.de
            link
            fedilink
            arrow-up
            2
            ·
            10 months ago

            What am I missing? I typically used it as a sanity check and would vet the changes. Never as a one-click modify. Or is there something else I should know about?

              • otacon239@feddit.de
                link
                fedilink
                arrow-up
                6
                ·
                10 months ago

                Ah, yeah. It was never meant to be a be all and all. Just something to clean up the complete trash before I started proofreading. Besides, these were emails the customer provided and could easily be changed afterwords. Their fault if we get bad emails in the list ¯\_(ツ)_/¯

                • elvith@feddit.de
                  link
                  fedilink
                  arrow-up
                  1
                  ·
                  edit-2
                  10 months ago

                  You’re completely correct. In practice, it’s usually good enough to just check for “.+@.+” or “.+@.+\…+”. Why? It’s broad enough to allow almost everything and it rejects the most obvious typos. And in the end, the final verification would be to send an email there which contains a link, that one has to click to finalize the signup/change. Even if you had a regex that could filter every possible adress that’s possible according to the standard, you still wouldn’t know whether it really exists.

              • dev_null@lemmy.ml
                link
                fedilink
                arrow-up
                4
                ·
                10 months ago

                I wrote a regex that matches 100% of email addresses and had no problems using it. It’s “.+@.+”

                • Feathercrown@lemmy.world
                  link
                  fedilink
                  English
                  arrow-up
                  1
                  ·
                  edit-2
                  10 months ago

                  Meme aside that’s what I’d use tbh. Or the ultimate email validation: just sending the signup email and if they typed an invalid email it won’t send

      • anton@lemmy.blahaj.zone
        link
        fedilink
        arrow-up
        2
        ·
        9 months ago

        While email addresses are technically a regular language but I have seen a the regex that takes up a whole page claiming to be the first standard compliant one.