Email Addresses
Regular expressions are frequently used for email address validation, and yet validating a simple email address is anything but simple.
My name is Ben Forta, and my email address is ben@forta.com.
(\ w+\ .)*\ w+@(\ w+\ .)+[A-Za-z]+
My name is Ben Forta, and my email address is ben@forta.com.
(\ w+\ .)*\ w+ matches the name portion of an email address (everything before the @). (\ w+\ .)* matches zero or more instances of text followed by ., and \ w+ matches required text (this combination matches both ben and ben.forta, for example). @ matches @. (\ w+\ .)+ then matches at least one instance of text followed by ., and [A-Za-z]+ matches the top-level domain (com, edu, us, or uk, and so on).
The rules governing valid email address formats are extremely complex. This pattern will not validate every possible email address. For example, it will allow ben..forta@forta.com (which is invalid) and will not allow IP addresses as the hostname (which are allowed). Still, it will suffice for most email validation, and so it may work for you.