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

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

How to get the ip address of VM and use it to configure SSH connection dynamically in Ansible -

javascript - Get parameter of GET request -