Regex to fail email domain with two consecutive dots -
i trying validate domain part of email , want check there not 2 consecutive dots in domain i.e. following not valid
- joe@ms..com
- joe@ms.com..uk
- joe@..ms.com
- joe@ms.com.au..
i have regex find
@+\.{2}|@.+\.{2}
but using regex attribute in .net , want build regex valid (i.e. 1 dots) not 1 fails
i thought ^
character meant
everything not expression
so thought ^(@+\.{2}|@.+\.{2})
have worked not nor .net framework emailaddress
attribute - stops joe@ms..com
not stop joe@ms.com..au
you can use negative lookahead in front of regex:
@(?!.*?\.\.)[^@]+$
which fail match if 2 consecutive dots present in domain anywhere.
[^@]
match 1 or more characters not @