r/ProgrammerHumor • • Sep 23 '22

Refactoring "Just working solution ".

Post image
54.8k Upvotes

355 comments sorted by

View all comments

Show parent comments

80

u/omgFWTbear Sep 23 '22

task of simplifying

I realized I could solve this one problem with a REGEX, and now I have two problems…

26

u/akatherder Sep 23 '22

I need a regex to validate email address.

(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=
?^_`{|}~-]+)*|" (?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b
\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*")@(?:(?:[a-z0-9]
(?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\
[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]
|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-z0-9-]*[a-z0-9]:(?:[\x01-\
x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c
\x0e-\x7f])+)\])

Well that was intuitive.

18

u/git0ffmylawnm8 Sep 23 '22

... aight imma head out chief this ain't it

11

u/[deleted] Sep 23 '22

You do know that the only sure-fire way of validating an email address is to try sending mail to it, right?

2

u/VitaminnCPP Oct 11 '22

I need regex to validate regex that validates email.

36

u/ThePyroEagle Sep 23 '22

Using regex is rarely a simplification.

26

u/omgFWTbear Sep 23 '22

9

u/[deleted] Sep 23 '22

I use this and think it is better than regex buddy.

https://regex101.com/

2

u/TheMacMini09 Sep 23 '22

Don’t forget that article was written in 2008. I would imagine there’s a lot of better tools than RegexBuddy that have been created in the last 14 years.

1

u/[deleted] Sep 23 '22

Regex buddy is still under development and is quite robust. I own it

1

u/SpaceShrimp Sep 23 '22

And it rarely cover all edge cases, and even less after someone some tries to modify it to add some functionality, and almost succeeds.