RegEx for SMTP Address Validation


Last week I opined about the cloud. None of that this week, you'll be glad to hear. Straight to business (if you discount the last two sentences).

Last week I also talked about a fabulous RegEx expression I collected during some recent B2C training. It could be used to validate password complexity.

This week I'll show you a RegEx expression that can be used to validate an email address.

 

^[a-zA-Z0-9.!£#$%&'^_`{}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$

 

We allow numbers, letters (upper and lower) and special characters followed by an @ sign. This then has to be followed by only numbers and letters (upper and lower) and full stops - "."

Nice. Now let's test with PowerShell.
 
Capture179

 

 

Comments (2)

  1. Bookmarked this blog.

    Thanks a lot !!!

  2. Rory Fewell says:

    Really helpful bit of regex that – will make note for future use. 🙂

Skip to main content