Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

My RegExp pattern alllowing double "@" in email

Hello who just have come.

I'm learning JavaScript RegExp rules. And i have wrote email validation pattern. But unfortunatley it allowing double "@" in examples.

Please help me to improve it.

^(?:\s|(?:[a-z]))(?:[a-zA-Z0-9]+.)+@(?:[a-zA-Z])+.[a-z]+\s+

Also screenshot available: enter image description here

like image 775
north.inhale Avatar asked Jun 08 '15 09:06

north.inhale


1 Answers

The reason that your regex allows second @ is . character:

^(?:\s|(?:[a-z]))(?:[a-zA-Z0-9]+.)+@(?:[a-zA-Z])+.[a-z]+\s+

                                                 ^

It allows any character. Just escape it with \. to make it dot-only.

like image 174
hsz Avatar answered Sep 22 '22 03:09

hsz