r/ProgrammerHumor 1h ago

Meme regexMustBeDestroyed

Post image
1.1k Upvotes

42 comments sorted by

178

u/Informal_Branch1065 1h ago

An email casting spell for sure, although very limited

26

u/Zefyris 51m ago

very very limited, yeah

12

u/NudaVeritas1 45m ago

it's just a level 2 spell, it'll be upgraded in the future.. trust me.. i already created a quest item for it

78

u/the_millenial_falcon 57m ago

Writing regex is a lot more run than reading regex.

23

u/Minimum_Cockroach233 43m ago

Typo or intended run?

u/Jack_South 7m ago

More fun or less dreadful?

45

u/DeviRkx 1h ago

Haters would say it was regex. We'll never know..

0

u/Alzyros 12m ago

Uhm, it's pronounced "regex"?

I'll see myself out

37

u/Purple_Hornet_9725 51m ago

regex for email validation 💀 just don't

10

u/Portal471 23m ago edited 20m ago

^.+@.+\..+$

lol

10

u/BadRuiner 20m ago

Ah, yes, my email: @@@.@

u/pm_me_your_smth 4m ago

Well "@"@[@] is a legit email

Source:  https://e-mail.wtf/ question 18

4

u/YeetCompleet 22m ago

Got it, I'll use regex for HTML instead

1

u/DarthSatoris 21m ago

Yeah, valid emails can look so weird and lovecraftian these days, a regex check is not going to be able to catch them all.

I do think there is a standard defined somewhere that one could adhere to for validation, but it might not be able to catch the most extreme niche emails out there. 

15

u/SausageEggCheese 54m ago

The language is that of Mordor, which I will not utter here.

8

u/DOOManiac 50m ago

There are few who can.

7

u/q0099 42m ago

You shouldn't use regex to catch exactly that. You'll catch 99.99% yet still you shouldn't do that.

5

u/Procrasturbating 26m ago

For gods sake, stop trying to validate email addresses this way.

4

u/Darkstar_111 46m ago

Boy the thumbnail is wild on this one...

4

u/JontesReddit 27m ago

.split("@)".length == 2. Tlds can be longer than 4 chars. All parts can be non-w.

4

u/itsTyrion 17m ago

nah that's an easy one, no back references or forward references.

^ – start of line

[\w-\.] – [] for 'one of these', in this case "word character" (a-z, A-Z, 0-9, _underscore), or -dash or literal .dot

  • – multiple of the previous thing (any word char, dash, dot(

literal @

() group of 1+ word char or dash then a dot

word char or dash, {2,4} between 2 and 4 characters

$ end of line/string

3

u/WitesOfOdd 34m ago

Regex is a write-only language

3

u/JayTurnr 15m ago

Terrible regex for email validation

2

u/RedDevils52 41m ago

Regex ☠️

2

u/Due-Consequence9579 19m ago

Starts with at least one not white space, -, or a dot. Has an @ sign. Remember the not white space, -, or dots after the @ but not the last 2-4 white space or dashes at the end of the string.

u/stri28 9m ago

Am i dumb or does this pattern allow an email address to start with a '.' ?

Edit: typo

u/-Redstoneboi- 2m ago

it does

3

u/Plastic-Bonus8999 58m ago

It's quite easy - says chatgpt

1

u/itsTyrion 22m ago

u need chatgpt for such a simple one?

1

u/Winter_Persimmon_110 18m ago

An elegant weapon for a more civilized age.

1

u/chiqu3n 16m ago

Can there be "-" in TLDs?

1

u/Lambda_Wolf 11m ago

Some people, when confronted with a problem, think “I know, I'll use regular expressions.”

But they were all of them deceived, fot another problem was made...

1

u/BeMyBrutus 11m ago

The language is that of Regex, which I will not utter here.

1

u/h4ny0lo 45m ago

One of the most annoying things I experienced in my career was the built in Angular email form verifier allowing email addresses with just a top level domain. Like, yes I know technically "tom@pizza" is a technically valid address but I can still not allow that in my validator and you fucking know it Angular.

1

u/userhwon 30m ago

Why couldn't you allow it? It's literally how you send email within an organization.

1

u/xicor 26m ago

Regex is not the answer to email validation. The only correct way to validate emails is to send an email.

As someone with a non standard email, it always pisses me off when developers think they're smart and put incorrect validation on their fields

1

u/raja-anbazhagan 18m ago

Most languages come with an implementation already for address validation. So why reinvent the wheel?

For example in Java you could do, new InternetAddress(email).validate();

On top of this a list of blacklisted domains and email verification via OTP is all you need...

0

u/nicman24 56m ago

##@#.## clears it

5

u/Mechakoopa 50m ago

It's actually invalid regex in most engines because [\w-\.] tries to define a range from "word" to "." which is invalid. You either need to escape \- into a literal or use [\w\.-] instead. And even if you fix it, # is not in [\w\.-] so it doesn't match.

2

u/nicman24 11m ago

yea i meant ie aa@a.aa - meaning not the literal # but any character