Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

regex for email validation [duplicate]

Tags:

regex

email

I have written the regex below for a really simple email validation. I plan to send a confirmation link.

/.*@[a-z0-9.-]*/i

I would, however, like to enhance it from the current state because a string like this does not yield the desired result:

test ,[email protected], test

The "test ," portion is undesirably included in the match. I experimented with word boundaries unsuccessfully.

  1. How should I modify?
  2. Even though I've kept this simple, are there any valid email formats it would exclude?

THANKS!

like image 385
ryonlife Avatar asked Feb 03 '09 17:02

ryonlife


Video Answer


1 Answers

It's a lot more complicated !!! See Mail::RFC822::Address and be scared...very scared.

like image 99
an0nym0usc0ward Avatar answered Oct 02 '22 13:10

an0nym0usc0ward