.Net useful common regular expressions

Common .Net Regular Expression Patterns List

Name Pattern Example
US zip code regex ^\d{5}(?:[-\s]\d{4})?$ 12345 or 12345-2345
Canadian zip code regex ^([ABCEGHJKLMNPRSTVXY]\d[ABCEGHJKLMNPRSTVWXYZ])\ {0,1}(\d[ABCEGHJKLMNPRSTVWXYZ]\d)$ M4B 1B4
US phone number regex \(?\d{3}\)?-? *\d{3}-? *-?\d{4} (123) 345-234
US Date (MM/dd/YYYY) regex ^(0?[1-9]|[12][0-9]|3[01])[\/](0?[1-9]|1[012])[\/]\d{4}$ 05/31/2016
24 Hour time regex ^(?:0?[0-9]|1[0-9]|2[0-3]):[0-5][0-9]$ 13:12
12 Hour time regex (AM/PM) ^(([0]?[0-9]|1[0-2]):[0-5][0-9][ ][aApP][mM])|((1[3-9]|2[0-3]):[0-5][0-9])$ 7:00 AM
Url regex ^(https?:\/\/)?([\da-z\.-]+)\.([a-z\.]{2,6})([\/\w \.-]*)*\/?$ http://www.test.com or www.test.com
IP address regex ^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$ 127.0.0.1
US social security number rgex ^([0-9]{3}[-]*[0-9]{2}[-]*[0-9]{4})*$ 123-09-2345