this post was submitted on 15 Jul 2026
76 points (98.7% liked)

Programmer Humor

42841 readers
279 users here now

Post funny things about programming here! (Or just rant about your favourite programming language.)

Rules:

founded 7 years ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
[–] wuphysics87@lemmy.ml 8 points 6 hours ago (1 children)

Isn't the whole point of regex to toil for 3 hours to write something very specific you will only ever use once?

[–] Zarobi@aussie.zone 5 points 5 hours ago* (last edited 5 hours ago) (1 children)

~~Isn't the whole point of regex to toil for 3 hours to write something ver~~y ~~sp~~e~~cific you will only ever u~~s~~e once?~~

/((?!([es]))y)(?:.*?)((?!(s))e)(?:.*?)(s)/

Tap for spoilerIt's a Regex that checks if the letters for the word "yes" exists within a text in order. I call it the yesnometer

[–] gedhrel@lemmy.world 3 points 5 hours ago (1 children)
[–] Zarobi@aussie.zone 2 points 4 hours ago

Nothing is wrong with that, but it will give you different output. I tend to like using capture groups just out of habit, it makes it more flexible and useful in future. Most of my co-workers hated Regex so I tried to make it easy for them.

I also wanted the letters to be as close together as possible. In this example it doesn't matter, but in other texts it might. Yours will find the first y, then the furthest possible e, then the furthest possible s. So you might get output where there's a y on line 1 and the e s at the very end of the text. Nothing wrong with that, it's just not what I was envisioning.

Also it's funnier in this context to have a complicated regex.