SQL Flow Field Guide

REGEXP_SUBSTR

Catalog support for SQL Server 2025 (17.x)

regular expression evaluation

What changes

Input
string, regex pattern, flags
Output or change
match result, position, count or replaced text
Return type
String.

Syntax at a glance

REGEXP_SUBSTR ( string_expression, pattern_expression [ , start [ , occurrence [ , flags [ , group ] ] ] ] )

Work example

Extract one matching substring from a structured text value.

Define which occurrence is needed and handle no match as a normal result case.

Check your work No match returns null and the pattern does not validate the whole string unless anchored.

Open Microsoft Learn for full syntax, permissions, and details for your version.