Project DescriptionSQLRX 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 StartedDownload the C# project then build and deploy it to your database via Visual Studio.
ORDownload the compiled functions as T-SQL scripts and run them in your database.
SQLRXThe 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 SQLRX
AreafunctionName(). For example SQLRX
TestisMatch() or SQLRX
ReplaceinsertAfter() 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.
*Test
- isMatch()
- isMultipleMatch()
- isMatchAt()
- isMatchLast()
- isMatchFirst()
- isMatchPartial()
- isMatchEmpty()
*Replace
- replaceAll()
- replaceFirst()
- replaceLast()
- replaceAt()
- replaceFor()
- insertAt()
- insertBefore()
- insertAfter()
- stripAt()
- stripAll()
*Extract
- getMatches()
- getFirstMatch()
- getLastMatch()
- getMatchAt()
- getExcept()
*Groups
*Helpers
- reSplit()
- reJoin()
- reTrim()
- reCount()
- reTest()
NoteIn 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.