I want to know how to prevent double quotes in the email address check in jquery.
I used this regex :
new RegExp(/^(([^<>()[\]\\.,;:\s@\"] (\.[^<>()[\]\\.,;:\s@\"] )*)|(\". \"))@((?:[\w-] \.)*\w[\w-]{0,66})\.([a-z]{2,15}(?:\.[a-z]{2})?)$/i);
How to add double quotes to it to ignore this case: "mariam1451"@yahoo.com
CodePudding user response:
Delete |(\". \")
from your expression.
(\". \")
is matching any email between""
|
acts like a boolean OR, so you are making a regex that would be accepted if there is match either before or after the|
The regex would then be like this:
new RegExp(/^(([^<>()[\]\\.,;:\s@\"] (\.[^<>()[\]\\.,;:\s@\"] )*))@((?:[\w-] \.)*\w[\w-]{0,66})\.([a-z]{2,15}(?:\.[a-z]{2})?)$/i);
CodePudding user response:
/^(([^<>()\[\]\\.,;:\s@"] (\.[^<>()\[\]\\.,;:\s@"] )*)|(". "))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9] \.) [a-zA-Z]{2,}))$/;