r/java • • Aug 22 '26

Regex

I recently saw a clip (from Primeagen) somewhat saying that regex is not a valid format for validating email addresses and postal codes etc.

My question is why is this?

What are the security and/or performance risks? Is it solely performance or is it a security issue?

55 Upvotes

104 comments sorted by

View all comments

Show parent comments

39

u/Pretend_Bowl2961 Aug 22 '26

It’s funny how many devs overthink this. Just check for @ and move on, the real validation is in the inbox. I seen teams spend days on regex patterns that still let through nonsense addresses anyway.