I need to improve a regex for email validator that is current regex I use:
'/^(\w[\+-\._\w]*@[-\._\w]*\w\.[-\w]{2,63})$/'
the issue is to improve this regex so it should filter emails like this:
"n,n@nn.nn" and "nn,nn@nn.nn";
First I have added a condition
(?!,)
after 6th symbol so the regex become so:
'/^(\w (?!,) [\+-\._\w]*@[-\._\w]*\w\.[-\w]{2,63})$/'
this solved the first issue "n,n@nn.nn" but not helped with "nn,nn@nn.nn"
so I added a new negative condition
[^\,]
after 21th symbol so the regex became so:
'/^(\w (?!,) [\+-\._\w] [^\,] *@[-\._\w]*\w\.[-\w]{2,63})$/'
that solved both issues, but in such case validator fails on correct email if the first part of email (left side from @) is only one symbol like this:
"a@aa.aa"
Please, advice me how to work it out.