Jean-Nicolas BERGER
4/1/2007 6:30:00 AM
You can work with searchString.value, wich is a string and not a
SqlString.
JN.
----- Original Message -----
From: "bdd" <bdd@discussions.microsoft.com>
Newsgroups: microsoft.public.sqlserver.programming
Sent: Sunday, April 01, 2007 5:10 AM
Subject: User defined regex function coded in C#
> Trying to create a function to regex through a SqlString data type. I am
> having problems casting or converting the sqlstring to a regex type. Here
> is
> the code:
>
> public static SqlString CF_SearchRegex(SqlString searchString)
> {
> string searchPattern = @"^(?<searchword>\w+)(?<therest>)?";
> Regex searchRegex = new Regex(searchPattern,
> RegexOptions.Compiled);
> Match searchMatch = searchString.Match(searchPattern);
> Match group1 = SearchMatch.Groups["searchword"];
> Match group2 = SearchMatch.Groups["therest"];
>
> return new SqlString(group1.toString() + group2.toString());
> }
>
> The compiler cannot convert the searchString to a Match object or a Regex
> object. I have tried both. Can someone point me in the right direction?