In this Microsoft SQL Server 2025 series:
- Dec 01: Microsoft SQL Server 2025 – Introduction and installation
- Dec 02: Microsoft SQL Server 2025 – New T-SQL functions – native JSON data type and some functions
- Dec 03: Microsoft SQL Server 2025 – New T-SQL functions – JSON Index
- Dec 04: Microsoft SQL Server 2025 – New T-SQL functions – Product()
- Dec 05: Microsoft SQL Server 2025 – New T-SQL functions – BASE64_ENCODE() and BASE64_DECODE()
- Dec 06: Microsoft SQL Server 2025 – New T-SQL functions – REGEXP_LIKE()
- Dec 07: Microsoft SQL Server 2025 – New T-SQL functions – REGEXP_SUBSTR() and REGEXP_REPLACE()
- Dec 08: Microsoft SQL Server 2025 – New T-SQL functions – REGEXP_INSTR() and REGEXP_COUNT()
Last two functions in the family of new T-SQL functions that were shipped with RegEx, are REGEXP_MATCHES() and REGEXP_SPLIT_TO_TABLE().
REGEXP_MATCHES()
Returns a table of captured substrings that match a regular expression pattern to a string. If no match is found, the function returns no row.
And the syntax is: REGEXP_MATCHES ( string_expression, pattern_expression [ , flags ] ).
This example returns all valid emails
SELECT
ID
,Name
,Email
FROM [dbo].[EMPLOYEES]
CROSS APPLY REGEXP_MATCHES(email, '^[a-zA-Z0-9. _%+-]+@[a-zA-Z0-9.]') AS RegexMatchEmail
But in general the REGEXP_MATCHES returns all the valid positions:
SELECT *
FROM REGEXP_MATCHES ('This is a blog post on topics of #SQLServer2025 #AzureSQL', '#([A-Za-z0-9_]+)');
We can see that the REGEXP_MATCHES returns a table of captured substrings that match regular expression (string starting with pound (#) sign followd by alphanumeric string). And since there are multiple matches, it shows all results in a table resultset.
REGEXP_SPLIT_TO_TABLE()
Returns a table of strings split, delimited by the regex pattern. And the syntax is:
REGEXP_SPLIT_TO_TABLE(string_expression,pattern_expression [ , flags ])
A simple example is:
SELECT *
FROM REGEXP_SPLIT_TO_TABLE ('A journey of a thousand miles begins with a single step. Step step.', '\s+');
But in detailed, it can break an email into table with split strings:
SELECT
Value
,ordinal
,email
FROM [dbo].[EMPLOYEES]
cross apply REGEXP_SPLIT_TO_TABLE(Email, '[\\.,@]+') as SplitEmail
And the email addresses are in table, with each word as a separate row.
Tomorrow we will look into the new T-SQL functions for reading REST API.
As always, the code is available at my Github: https://github.com/tomaztk/SQLServer2025
Happy coding!





[…] Dec 09: Microsoft SQL Server – New T-SQL functions – REGEXP_MATCHES() and REGEXP_SPLIT_TO_TABLE() […]
LikeLike
[…] Dec 09: Microsoft SQL Server – New T-SQL functions – REGEXP_MATCHES() and REGEXP_SPLIT_TO_TABLE() […]
LikeLike
[…] Dec 09: Microsoft SQL Server – New T-SQL functions – REGEXP_MATCHES() and REGEXP_SPLIT_TO_TABLE() […]
LikeLike
[…] Dec 09: Microsoft SQL Server 2025 – New T-SQL functions – REGEXP_MATCHES() and REGEXP_SPLIT_TO_TABLE() […]
LikeLike
[…] Dec 09: Microsoft SQL Server 2025 – New T-SQL functions – REGEXP_MATCHES() and REGEXP_SPLIT_TO_TABLE() […]
LikeLike
[…] Dec 09: Microsoft SQL Server 2025 – New T-SQL functions – REGEXP_MATCHES() and REGEXP_SPLIT_TO_TABLE() […]
LikeLike
[…] Dec 09: Microsoft SQL Server 2025 – New T-SQL functions – REGEXP_MATCHES() and REGEXP_SPLIT_TO_TABLE() […]
LikeLike
[…] Dec 09: Microsoft SQL Server 2025 – New T-SQL functions – REGEXP_MATCHES() and REGEXP_SPLIT_TO_TABLE() […]
LikeLike
[…] Dec 09: Microsoft SQL Server 2025 – New T-SQL functions – REGEXP_MATCHES() and REGEXP_SPLIT_TO_TABLE() […]
LikeLike
[…] Dec 09: Microsoft SQL Server 2025 – New T-SQL functions – REGEXP_MATCHES() and REGEXP_SPLIT_TO_TABLE() […]
LikeLike
[…] Dec 09: Microsoft SQL Server 2025 – New T-SQL functions – REGEXP_MATCHES() and REGEXP_SPLIT_TO_TABLE() […]
LikeLike
[…] Dec 09: Microsoft SQL Server 2025 – New T-SQL functions – REGEXP_MATCHES() and REGEXP_SPLIT_TO_TABLE() […]
LikeLike
[…] Dec 09: Microsoft SQL Server 2025 – New T-SQL functions – REGEXP_MATCHES() and REGEXP_SPLIT_TO_TABLE() […]
LikeLike
[…] Dec 09: Microsoft SQL Server 2025 – New T-SQL functions – REGEXP_MATCHES() and REGEXP_SPLIT_TO_TABLE() […]
LikeLike
[…] Dec 09: Microsoft SQL Server 2025 – New T-SQL functions – REGEXP_MATCHES() and REGEXP_SPLIT_TO_TABLE() […]
LikeLike