SQL Server RegExp

17.07.2008 (2:05 пп) – Filed under: codding
sp_dbcmptlevel db_name, 90EXEC sp_configure 'show advanced options' , '1';goreconfigure;goEXEC sp_configure 'clr enabled' , '1'goreconfigure;EXEC sp_configure 'show advanced options' , '1';go
public static partial class UserDefinedFunctions{    public static readonly RegexOptions Options =        RegexOptions.IgnorePatternWhitespace |        RegexOptions.Singleline;

    [SqlFunction]    public static SqlString RegexMatch(SqlChars input, SqlString pattern)    {        Regex regex = new Regex(pattern.Value, Options);        string data = new string(input.Value);        data.ToLower();        Match aMatch = regex.Match(data);        return aMatch.ToString();    }};
select dbo.RegexMatch( N'123-45-6789', N'\d{2}' )

http://msdn.microsoft.com/en-us/magazine/cc163473.aspx