Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
Log in  ::  Register  ::  Not logged in

Get your favorite SSC scripts directly in SSMS with the free SQL Scripts addin. Search for scripts directly from SSMS, and instantly access any saved scripts in your SSC briefcase from the favorites tab.
Download now (direct download link)

Use of regular expressions in TSQL -- version 2

By Bert De Haes,

This script creates 2 new system functions ****************************************** NEW: 1. functions will be case sensitive if database is 2. Replace all or only first occurence ****************************************** fn__regexp_test(@String,@Pattern) returns int execute the method test(@String) on the regular expressions @Pattern returns : 0 : no match 1 : match null : one of the parameters was null anything else : error from sp_OA procedure fn__regexp_replace(String,@Pattern,@Replace,@Global) returns varchar execute the method Replace(@String,@Replace) on the regular expressions @Pattern Global = 1 ( Default ) replaces all occurences, Global = 0 only the first occurance returns : null on failure of an sp_OA procedure null if one of the paremeters is null the result of the replace

Total article views: 427 | Views in the last 30 days: 1
Related Articles

Splitting Strings Based on Patterns

Splitting strings based on patterns supported by LIKE and PATINDEX can be an interesting way to addr...


T-SQL 2005 String Pattern??

T-SQL 2005 String Pattern??


Replacing strings

Replacing data


split string between 2 patterns

This function is used to split the string between two patterns.


Tame Those Strings! Part 3 - Using REPLACE

The third part of Steve Jones's series on programming and manipulating strings in T-SQL dealing with...


Join the most active online SQL Server Community

SQL knowledge, delivered daily, free:

Email address:  

You make SSC a better place

As a member of SQLServerCentral, you get free access to loads of fresh content: thousands of articles and SQL scripts, a library of free eBooks, a weekly database news roundup, a great Q & A platform… And it’s our huge, buzzing community of SQL Server Professionals that makes it such a success.

Join us!

Steve Jones

Already a member? Jump in:

Email address:   Password:   Remember me: Forgotten your password?
Steve Jones