Project Description
SQLRX is a collection of CLR functions that give you the ability to use common regular expression methods in your T-SQL code.

Regular Expressions Library for SQL Server via the CLR.

Note: I was hoping to publish this May 1st, I will try to get the files up this week.

Getting Started
Download the C# project then build and deploy it to your database via Visual Studio.
Download the compiled functions as T-SQL scripts and run them in your database.

The following has changed drastically since I started the project. I will update this this weekend.

In the database and in the code these functions have the pattern SQLRXAreafunctionName(). For example SQLRXTestisMatch() or SQLRXReplaceinsertAfter() etc... They are setup this way to make them easy to find and organize in SQL Management Studio's Object Explorer, but they can be renamed easily.

  • isMatch()
  • isMultipleMatch()
  • isMatchAt()
  • isMatchLast()
  • isMatchFirst()
  • isMatchPartial()
  • isMatchEmpty()

  • replaceAll()
  • replaceFirst()
  • replaceLast()
  • replaceAt()
  • replaceFor()
  • insertAt()
  • insertBefore()
  • insertAfter()
  • stripAt()
  • stripAll()

  • getMatches()
  • getFirstMatch()
  • getLastMatch()
  • getMatchAt()
  • getExcept()

  • reSplit()
  • reJoin()
  • reTrim()
  • reCount()
  • reTest()

In my opinion there are definitive examples of using regular expressions in SQL to solve practical problems and there are just as many cases where SQL can handle the problem without relying on the CLR.

Good example:

Create a constraint based on a regular expression pattern.

Bad example:

Overusing SQLRX_isMatch(input,pattern) when a simple LIKE '%X%' would suffice.

Last edited May 8, 2009 at 1:44 PM by CJRandolph, version 8