315
submitted 9 months ago by mac@programming.dev to c/comics@programming.dev

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.]

all 16 comments
sorted by: hot top controversial new old
[-] otacon239@feddit.de 32 points 9 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.

[-] UndercoverUlrikHD@programming.dev 36 points 9 months ago

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

Hmm...

[-] anton 2 points 8 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.

[-] Norodix@lemmy.world 17 points 9 months ago

No I dont do that. Stop asking. That is not me in the picture.

[-] pikasaurX4@lemm.ee 15 points 9 months ago

The image wouldn’t load for me but your transcript was perfect, thank you

[-] mac@programming.dev 10 points 9 months ago

Credit to explainxkcd for that one, their pages are great

[-] SatanicNotMessianic@lemmy.ml 15 points 9 months ago

I’ve been in the industry for about 30 years now, and I still will break out some command line Perl when I need to regex something.

[-] Diplomjodler@feddit.de 10 points 9 months ago* (last edited 9 months ago)

I've never bothered to learn regex because I can do this sort of stuff easily in Python. For any non-trivial job it's better to have things like error handling, statistics, logs and *gasp* readability.

[-] DoYouNot@lemmy.world 12 points 9 months ago

Are you not using regex in Python to do that?

[-] Diplomjodler@feddit.de 1 points 9 months ago
[-] BetterDev@programming.dev 13 points 9 months ago

Regex is fast and useful though. It's a tool in your toolbox that make certain situations extremely easy as the comic depicts.

[-] Diplomjodler@feddit.de 2 points 9 months ago

Sure. I'm just saying it was never worth the effort to learn it for me.

[-] DoYouNot@lemmy.world 9 points 9 months ago

I guess I'm just not sure what your doing in Python that is equivalent in some way to regex without using the re library. Like, do you mean you're using looped ifs and raw strings to do something similar?

[-] pivot_root@lemmy.world 3 points 9 months ago* (last edited 9 months ago)

Learning basic regex takes less than a day. Learning extended regex takes a day or two.

If you're often writing Python scripts to scan strings and match patterns, I can almost guarantee you're actually wasting more of your time avoiding having to use regex.

In fact, if you're working with large datasets, you're wasting even more time waiting for your scripts to finish. Python's regular expression engine is written in C, which is considerably faster than plain Python.

[-] teststodon@mastodon.social 1 points 9 months ago
this post was submitted on 01 Feb 2024
315 points (100.0% liked)

Comics

446 readers
1 users here now

A community for sharing comics related to programming

Icon base by Delapouite under CC BY 3.0 with modifications to add a gradient

founded 10 months ago
MODERATORS