foreveryoung
Programmer
I have created my first CLR in SQL to use regular expressions designed to match certain codes. Trouble is that I am trying to match the text HE1 in a string and keep getting a match for HE12 which is what I want to avoid. I have tried dbo.RegMatch(N'HE1[^0-9]' but this doesnot match anything. The vb.net is
Code:
Imports System
Imports System.Data
Imports System.Data.SqlClient
Imports System.Data.SqlTypes
Imports Microsoft.SqlServer.Server
Imports System.Text.RegularExpressions
Partial Public Class UserDefinedFunctions
<Microsoft.SqlServer.Server.SqlFunction()> _
Public Shared Function RegMatch(ByVal REGULAREXP As String, ByVal Comments As String) As Integer
' Add your code here
Dim rx As New Regex(REGULAREXP, RegexOptions.IgnoreCase) ' Or RegexOptions.IgnorePatternWhitespace)
If rx.Match(CType(Comments, String)).Success = True Then
Return 1
Else
Return 0
End If
End Function
End Class