Code
using System;
using System.Data;
using System.Data.SqlClient;
using System.Data.SqlTypes;
using Microsoft.SqlServer.Server;
using System.Text.RegularExpressions;
// 示意代码
public partial class UserDefinedFunctions
{
public static readonly RegexOptions Options =
RegexOptions.IgnorePatternWhitespace | RegexOptions.Singleline;
[Microsoft.SqlServer.Server.SqlFunction]
public static string RegexValue(SqlChars input, SqlString pattern)
{
Regex regex = new Regex(pattern.Value, Options);
return regex.Match(new string(input.Value)).Value;
}
}