Checks whether a string matches a Regular Expression pattern.

  • Free Function
  • SQL Server Compatibility: 2008, 2012, 2014, 2016, 2017


SELECT @Text, @RegexPattern)


Name Type Description
@Text nvarchar(MAX) String to be tested for a match.

@RegexPattern nvarchar(4000) String expression containing a regex expression. See Regular Expression Language – Quick Reference for more information.

Return Type:


Return Values:

0 = Text does NOT MATCH the regular expression pattern
1 = Text MATCHES the regular expression pattern

Sample Usage:

The following is a handy example of validating an email:

See Also: