Friday, March 18, 2005

xp_pcre - Regular Expressions in T-SQL

"An Extended Stored Procedure to use regular expressions in T-SQL.

...

xp_pcre is so named because it uses the "Perl Compatible Regular Expressions" library. This library is available at http://www.pcre.org/. (You don't need to download the PCRE library in order to use xp_pcre. The library is statically linked.)


Overview

There are six extended stored procedures in the DLL:

  • xp_pcre_match
  • xp_pcre_match_count
  • xp_pcre_replace
  • xp_pcre_format
  • xp_pcre_split
  • xp_pcre_show_cache

The parameters of all of these procedures can be CHAR, VARCHAR or TEXT of any SQL Server-supported length. The only exception is the @column_number parameter of xp_pcre_split, which is an INT.


If any required parameters are NULL, no matching will be performed and the output parameter will be set to NULL. (Note: This is different than the previous version which left the parameters unchanged.)



..."


Oh yeah, this could rock. I know some RegEx hero's who might really like this. I've used RegEx just enough to be dangeours and am pretty much hooked too.

Seems kind of funny that I'm finding so many cool Extended Stored Procedures on the eve of SQL 2k5...

Now to see if there's any interest from my DBA's (I know you're reading this you rat... err... um... Great guys, all and one... That's my story and I'm sticking with it :)

(Via the always outstanding Larkware - The Daily Grind 582)

No comments: