Using a regular expression function on SQL Server
Before you begin
- You have deployed the regular expression function to the SQL server.
- You have tested the regular expression.
- You have selected the Profiling perspective.
About this task
Here
is the code used in this example:
Using System;
Using Microsoft.SqlServer.Server;
Using System.Text.RegularExpressions;
Public partial class RegExBase
{
[SqlFunction(IsDeterministic = true, IsPrecise = true)]
Public static int RegExMatch( string matchString , string pattern)
{
Regex r1 = new Regex(pattern.TrimEnd(null));
if (r1.Match(matchString.TrimEnd(null)).Success == true)
{
return 1 ;
}
else
{
return 0 ;
}
Using
}
};
Procedure
Results
For more detailed information on how to declare a regular expression function in Talend Studio, see Defining a query template for a specific database and Declaring a User-Defined Function in a specific database.