Regular expression captures



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


.



Relevant Pages

  • Re: Regex optimization
    ... I was hoping that someone with knowledge of the Regex engine could ... match per string for either Regex. ... reluctant modifier, may be slower .*?, +? ... Variable parts will try to capture as much as possible. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Regex Capture problem
    ... "learned" my regex using a freeware utility that had slightly different ... was trying to capture instead of. ... I have used Regex utilities before, so I understand the concepts of text ... Function RESub(str As String, SrchFor As String, ReplWith As String) As String ...
    (microsoft.public.excel.programming)
  • regex: capture groups and term binding
    ... I'm building a regex for this string and it's pretty straightforward. ... Only prerequisite is to capture all numbers for later Ruby fun: ... a rule-set from a YAML file to create output. ...
    (comp.lang.ruby)
  • Re: Regular expression captures
    ... > From the following string I would like to capture text. ... This action has been executed via Console ... > the RegEx class but I'm having troubles retrieving "Console". ... The captures will always include the substring that matches the whole ...
    (microsoft.public.dotnet.framework)
  • Re: wprintf() could not display unicode chars which is > 255 to console?
    ... > console window with formatting strings. ... Unicode and the Windows console is a tricky business. ... string msg, action; ... In Japanese you should have no spaces, and the translator can remove them. ...
    (microsoft.public.vc.mfc)