Regular expression captures
- From: "Erik Tamminga" <thisiskept@xxxxxxxxxxx>
- Date: Sun, 17 Apr 2005 23:08:12 +0200
Hi,
>From the following string I would like to capture text.
String: This action has been executed via Console
First of all I like to know if this is the text I need: it must contain
"This action has been executed via".
Secondly I would like to know "Console"
How can Regular expressions help me in this. I've tried various things with
the RegEx class but I'm having troubles retrieving "Console". The
match.Captures collection always seems to contain the string searched, not
only the captured part.
RegEx r = RegEx( "This action has been executed", RegExOptions.IgnoreCase)
if (r.Matches( myString).Count > 0)
{
Here matches are found and r.Matches[0].Captures.Count > 0.
Why is ...Captures.Count > 0, I did ask for a capture?
}
RegEx q = RegEx( "(C\w+)", RegExOptions.IgnoreCase)
if (q.Matches( myString).Count > 0)
{
Here matches are found and r.Matches[0].Captures.Count > 0.
This is where I expected the capture!!
}
regards,
Erik
.
- Follow-Ups:
- Re: Regular expression captures
- From: Jon Shemitz
- Re: Regular expression captures
- Prev by Date: Re: Why does aspx pages crash my machine?
- Next by Date: Re: Regular expression captures
- Previous by thread: Re: MSDN Universal subscription changes (level and pricing)
- Next by thread: Re: Regular expression captures
- Index(es):
Relevant Pages
|
|