Code Review: CLR RegexSubstring
Posted
by OMG Ponies
on Stack Overflow
See other posts from Stack Overflow
or by OMG Ponies
Published on 2010-05-12T21:13:54Z
Indexed on
2010/05/12
21:24 UTC
Read the original article
Hit count: 179
Could this be better? .NET 2.0 compatibility for SQL Server 2005:
public static SqlString RegexSubstring(SqlString regexpattern,
SqlString sourcetext,
SqlInt32 start_position)
{
SqlString result = null;
if (!regexpattern.IsNull && !sourcetext.IsNull && !start_position.IsNull)
{
int start_location = (int)start_position >= 0 ? (int)start_position : 0;
Regex RegexInstance = new Regex(regexpattern.ToString());
result = new SqlString(RegexInstance.Match(sourcetext.ToString(),
(int)start_position).Value);
}
return result;
}
© Stack Overflow or respective owner