Click here to monitor SSC
SQLServerCentral is supported by Redgate
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: 429 | Views in the last 30 days: 2
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...