Common REGEX Validation Expressions


SQL Server 2000: Not Tested

SQL Server 2005: Not Tested

SQL Server 2008: Not Tested

SQL Server 2008R2: Not Tested

SQL Server 2012: Not Tested


Author: Unknown

Date: 9 Mar 2011


This is a list of REGEX strings to validate some common formatted identifiers.

It is not a comprehensive list, nor have I had the opportunity to transalte these into TSQL Functions, but hopefully they will provide a good starting point.

If anyone has any that are not mentioned, I'll gladly add them to the list

Internet URL: http(s)?://([\w-]+\.)+[\w-]+(/[\w- ./?%&=]*)?

US Phone Number: ((\(\d{3}\) ?)|(\d{3}-))?\d{3}-\d{4}

US Social Security Number: \d{3}-\d{2}-\d{4}

US ZIP Code: \d{5}(-\d{4})?

URI: \b(\S+)://([^:]+)(?::(\S+))?\b