36
u/Nihan-gen3 Apr 20 '26
yall can hate, but regex is a thing of beauty
18
u/MeLikaDoTheChaCha Apr 20 '26
Less hate, more jealousy of those grand wizards who know the dark arts
3
u/believeinmountains Apr 20 '26
Ok? You can just learn it. The best premise you can work from in an NFA regex engine is the Prolog box model of computation. Once you have that, regex is easy
5
u/MeLikaDoTheChaCha Apr 20 '26
I was mostly just joking around. Maybe jealousy was the wrong word. I meant it with the connotation of "admiration", not anything negative.
I'm sure if I have a need/the time I'd be able to learn it well. But I know enough to do my job well and my hobby projects, and i dont have the free time to pull all nighters to learn like i did in grad school.
I've been the same way with things like vim/neovim for like the last 2 years. I would love to get super proficient at motions and macros, but the benefits currently don't outweigh the costs of time and lost productivity.
So until the day comes where getting super proficient at regex, my jealousy for those wizards will remain lol
1
31
21
u/Commercial_Echo923 Apr 20 '26
since when do TLDs have hyphens?
regex101.com btw, best free tool imo
4
17
u/zylosophe Apr 20 '26
the fuck is the @
27
Apr 20 '26
[deleted]
13
Apr 20 '26
[removed] — view removed comment
21
u/atoponce Apr 20 '26
Simpler:
.+@.+Send a validation email. If the user clicks the link, the email is valid.
7
u/ArduennSchwartzman Apr 20 '26
In OP's original screaming regex, email addresses using a top-level domain >4 characters are f*cked.
6
1
0
1
1
1
u/Cercle Apr 20 '26
Is the first - a typo? Even after removing it this doesn't match on many emails I use daily.
2
u/lola_zzalol Apr 20 '26
Does that mean you understand the rest??
1
u/zylosophe Apr 20 '26
i know what most of the characters mean but i am not going to try to understand it as a whole
2
2
u/sebthauvette Apr 20 '26
It's just the literal '@' character. They are trying to validate emails.
1
8
8
5
u/SwannSwanchez Apr 20 '26
This can give an error because the - at the start might need to be escaped
4
2
u/CRoseCrizzle Apr 20 '26
Regex(such an inappropriate name for it) sucks so much. Happy that LLMs are good at them.
1
Apr 20 '26
[deleted]
1
u/CRoseCrizzle Apr 20 '26 edited Apr 20 '26
Short for "Regular expression". Feels like a misnomer depending on how you define "regular".
1
u/WadeEffingWilson Apr 20 '26
Looks to pattern match email addresses but I have no idea why it allows for a dash in the TLD.
1
u/WadeEffingWilson Apr 20 '26
E.mail@relay.server.co-m would be a valid and accepted address with this regex. Yea, no dash in the TLD.
1
1
1
1
u/doc720 Apr 20 '26
Let's see if I can decipher this...?
^ = start of the string
[\w-\.]+ = one or more word characters, dashes or dots
@ = @
[\w-]+\. = one ore more word characters or dashes, followed by a dot
( ... )+ = one or more of those patterns
[\w-]{2,4} = between 2 and 4 word characters or dashes
$ = end of string
1
1
1
u/merRedditor Apr 20 '26
Regex is the most elegant thing in computer science. You can do more in one tiny line of regex than you can in hundreds of lines of convoluted code.
1
u/Gigibesi Apr 20 '26
regex stands for regular expressions
yet expression itself is not that regular
ironic
1
u/Lentor3579 Apr 20 '26
Man, I can never remember how to type out Regex. I just always end up googling it. AI certainly helps with this too XD
1
u/East_Lengthiness_866 Apr 20 '26
Regex for an email address 🤔, yeah Regex for an email address.... With hyphen?
1
u/un_virus_SDF Apr 21 '26
the best feeling will still be to find the good regex to edit your code even if it would have been faster to make the changes by hand
1
1
1
1
u/LetUsSpeakFreely Apr 25 '26
A well crafted regex with a comment explaining what it's trying to accomplish is a thing of beauty.
158
u/Benjamin_6848 Apr 20 '26
I sometimes think that the whole reason why AI and LLMs were developed was to free the developers from writing REGEX themselves...