I have a regular expression to validate email:
Validemail = ^[^\\^~`'!@$#=%&*()+|{}:;,><?\"\\/\\[\\]\\\\\\s-\\.]([^\\^~`'!@$#=%&*()+|{}:;,><?\"\\/\\[\\]\\\\\\s\\.]|\\.(?!\\.+?))*[^\\^~`'!@$#=%&*()+|{}:;,><?\"\\/\\[\\]\\\\\\s-\\.]@[^\\^~`'!@$#=%&*()+|{}:;,><?\"\\/\\[\\]\\\\\\s\\.]*[^\\^~`'!@$#=%&*()+|{}:;,><?\"\\/\\[\\]\\\\\\s-\\.]\\.(?!\\.+?)[^\\^~`'!@$#=%&*()+|{}:;,><?\"\\/\\[\\]\\\\0-9\\s-\\_]{2,40}$$
This validation is accepting EG: kate@stack---overlow.com
However I want to restrict the domain name after @
and before .
so have only 1 hyphen.
Update:
I would not prefer making that check using contains
rather make it a part of regex.