[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.sqlserver.programming

User defined regex function coded in C#

bdd

4/1/2007 3:10:00 AM

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?
2 Answers

Jean-Nicolas BERGER

4/1/2007 6:30:00 AM

0

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?


bdd

4/1/2007 10:48:00 AM

0

Yes the intellisense does work in VS .net! This is why I do this as a hobby
only!

Thank you

"Jean-Nicolas BERGER" wrote:

> 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?
>
>
>