SQL Flow Field Guide

REGEXP_COUNT

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
int

Syntax at a glance

REGEXP_COUNT ( string_expression, pattern_expression [ , start [ , flags ] ] )

Work example

Count pattern matches when a row needs a quick structure check.

Use a nonoverlapping pattern and compare the count with a small hand-checked sample.

Check your work A count of zero means no match and does not prove that the full value follows a schema.

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