Regex in Framework 1.1 help

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • John B

    Regex in Framework 1.1 help

    Hi,
    Can someone please test the regex below in .NET Framework 1.1 and let me
    know the results.

    Running in 2.0, it does not capture the line number if there are any
    nonmatching line numbers (such as the second line).

    TIA

    JB

    string pattern = @"^\ *at\ (?:(?:(?<target >.+?)\x3Aline \
    (?<line>\d+))|( ?<target>.*))\w *$";
    Regex regex = new Regex(pattern, RegexOptions.Co mpiled |
    RegexOptions.Ig noreCase | RegexOptions.Mu ltiline |
    RegexOptions.Ig norePatternWhit espace);

    MatchCollection matches = regex.Matches(@ "
    at fubar1():line 200
    at fubar2()
    ");

    foreach (Match match in matches)
    {
    Console.WriteLi ne("target found: {0}",
    match.Groups["target"].Success);
    Console.WriteLi ne("target was: {0}",
    match.Groups["target"].Value);
    Console.WriteLi ne("line found: {0}",
    match.Groups["line"].Success);
    Console.WriteLi ne("line was: {0}",
    match.Groups["line"].Value);
    }
Working...