On my frontend, I have a regex in javascript to detect if the email was correct.
^(([^<>()[\]\\.,;:\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,}))$
Current backend Regex validation, on .NET is:
Regex.IsMatch(email, @"\A(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?)\Z", RegexOptions.IgnoreCase);
I want to replace the .NET regex by the javascript one But I'm really "lost" in the begin/end characters.
In the .NET regex, have \A and \Z the same utility than ^ and $ in my javascript one?
I tried to replace my .NET regex as follows, but it doesn't detect valid string even if in Javascript it was correct:
Regex.IsMatch(email, @"\A(([^<>()[\]\\.,;:\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,}))\Z", RegexOptions.IgnoreCase);
\Aand\Zare not supported and$does not behave the same.