Regular Expression Frustration

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

    Regular Expression Frustration

    Greetings,

    I'm using a custom WebBrowser control:



    When I get the DocumentSource of a web page I browsed, and run a regular
    expression against it, the Expression never matches anything, nothing,
    nadda. Never. I know it is a correct Regular Expression because if I use
    the intrinsic WebBrowser control, it the expression works. I know that if I
    view the DocumentSource in the Text Visualizer, and copy-paste the contents
    into Regulator, the regular expresssion works. If I write the contents of
    the DocumentSource to a file of any encoding (tried ASCII, UTF8 and
    Unicode), then open that file in any text editor and run a Regular
    Expression search (even from within Visual Studio itself), it matches
    exactly what I want. But even though Visual Studio itself matches it, if I
    then load that same file and run Regex.Matches against it, it won't ever
    match anything try as I might.

    But Regex class will never match it, even if I load the text file into
    another variable and Regex that instead, it'll never match. I'm trying to
    figure out what kind of problems this could be. I have tried normalizing
    the encoding, even examining the memory locations and I can't see any
    encoding problems. But I'm at a loss. I have encountered this problem once
    in the past consuming Web Services but do not recall the solution, and this
    was many years ago..

    I'm using Visual Studio 2008 Team Suite but I can replicate the problem in
    Visual Studio 2005, also.

    Perhaps someone here can identify the symptoms and already knows what the
    problem is.


    Thanks,
    Shawn


  • Shawn B.

    #2
    Re: Regular Expression Frustration

    But Regex class will never match it, even if I load the text file into
    another variable and Regex that instead, it'll never match. I'm trying to
    Well, even though it worked just fine yesterday and weeks and months before
    that, after 12 hours trying to figure out what the problem is, I finally
    decided to play with options and that did the trick:

    Regex regex = new Regex(pattern, RegexOptions.EC MAScript |
    RegexOptions.Ig noreCase);


    Thanks,
    Shawn


    Comment

    Working...