I'm trying to create a EMAIL regular expression. This is what I'm trying to achieve:
“_A-Za-z0-9-” , optional follow by “.[_A-Za-z0-9-]“, and end with a “@” symbol. The email’s domain name must start with “A-Za-z0-9″, follow by first level Tld (.com, .net) “.[A-Za-z0-9]” and optional follow by a second level Tld (.com.au, .com.my) “ .[A-Za-z]{2,}”, where second level Tld must start with a dot “.” and length must equal or more than 2 characters.
This is what I have so far:
([a-zA-Z0-9_\-\.]+)@((\[[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})(\w?\.[A-Za-z]{2,})
not working for me. I would like it to validate these emails:
myname@compgg.com
ffdicot@foobar.com.au
i3dicot@foobar.co.uk
and NOT:
myname@foobar.foo.bar.com
any suggestions?