29 December 2016
Databases store text, and the best way to manipulate text is to use a regular expression (‘regex’). Using regular expressions in SQL queries has been possible in many database engines for decades.
Now you can use regular expressions in SQL Server queries, too. I’ve created an open-source project, sql-server-regex, that lets you run regular expressions in T-SQL queries using scalar and table-valued functions.
The most common regular expression use cases are supported, including Match, Split, Group Match, and Replace.
You can use it with all versions of SQL Server that support SQL CLRs. That’s every version since SQL Server 2005, except for SQL Azure.
The sql-server-regex code is being tuned for performance and tested for edge-case bugs. If you’d like to help, fork the code on GitHub and get going!