regex - C#-Regular expression for email, but exclude "hotmail,gmail,yahoo" -
how can rewrite regular expression in order match email addresses, not those
contains "hotmail,gmail , yahoo". far wrote this:
^([a-za-z0-9_\-\.]+)@(?<!hotmail|gmail|yahoo)((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-za-z0-9\-]+\.)+))([a-za-z]{2,4}|[0-9]{1,3})(\]?)$
change negative lookbehind negative lookahead removing <
, , reposition follows
^([a-za-z0-9_\-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(?!hotmail|gmail|yahoo)(([a-za-z0-9\-]+\.)+))([a-za-z]{2,4}|[0-9]{1,3})(\]?)$
the above assumes "hotmail,gmail , yahoo"
directly follow @
.
shorter equivalent:
@"^([\w.-]+)@(\[(\d{1,3}\.){3}|(?!hotmail|gmail|yahoo)(([a-za-z\d-]+\.)+))([a-za-z]{2,4}|\d{1,3})(\]?)$"
Comments
Post a Comment