Regular Expressions

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Justin Rich

    Regular Expressions

    using .net 2.0.50110

    String line;
    RegexOptions options = ((RegexOptions. IgnorePatternWh itespace |
    RegexOptions.Si ngleline)| RegexOptions.Ig noreCase);

    Regex headerRE = new
    Regex(@"\\d{5,5 }(?<an8>\\d{5,5 })\\s(?<bu>\\d{ 2,2}).(?<mcu>\\ d{3,3})",option s);

    Match headerM = headerRE.Match( line);
    while(headerM.S uccess)
    ......

    line = aaa,bbbbb 0001047611 19-372 MFG10

    it should match and pull the middle numbers...
    i ran it in The Regulator and its ok and i ran it at
    http://www.regexlib.com/RETester.aspx and the regular expression is ok.

    i step through the code and the line is ok.. so i have no idea why
    headerM.Success is always false!
    also line comes from a file read from StreamReader.Re adLine


    Thanks
    Justin


  • Justin Rich

    #2
    Re: Regular Expressions

    im stupid, sorry...

    i used the @ and double \\

    to much copy and paste and not enough understanding :-/


    "Justin Rich" <jrich523@yahoo .spam> wrote in message
    news:Oq$48k7VFH A.228@TK2MSFTNG P12.phx.gbl...[color=blue]
    > using .net 2.0.50110
    >
    > String line;
    > RegexOptions options = ((RegexOptions. IgnorePatternWh itespace |
    > RegexOptions.Si ngleline)| RegexOptions.Ig noreCase);
    >
    > Regex headerRE = new
    > Regex(@"\\d{5,5 }(?<an8>\\d{5,5 })\\s(?<bu>\\d{ 2,2}).(?<mcu>\\ d{3,3})",option s);
    >
    > Match headerM = headerRE.Match( line);
    > while(headerM.S uccess)
    > .....
    >
    > line = aaa,bbbbb 0001047611 19-372 MFG10
    >
    > it should match and pull the middle numbers...
    > i ran it in The Regulator and its ok and i ran it at
    > http://www.regexlib.com/RETester.aspx and the regular expression is ok.
    >
    > i step through the code and the line is ok.. so i have no idea why
    > headerM.Success is always false!
    > also line comes from a file read from StreamReader.Re adLine
    >
    >
    > Thanks
    > Justin
    >[/color]


    Comment

    Working...