@"^([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})(\]?)$";
The regular expression above is used on a C# .net site to validate email addresses. It restricts what comes after the domain to be characters A-Z and can be 2 to 4 letters long.
microsoft.co.uk passes
microsoft.com passes
microsoft.co.fred passes
microsoft.co.freda fails
I need to change the expression so it allows any length strings to occur after the domain.
But if I change the third line to:
@".)+))([a-zA-Z]|[0-9])(\]?)$";
I would have thought that would remove the length restriction. But it doesn't. It makes .com and .co.uk addresses fail.
How can I change the expression to allow:
Jim@somecompany.longwordhere
or
Jim@somecompany.longwordhere.longwordhere
with no restriction on how long 'longwordhere' is and with it being able to be letters or numbers?