Regular Expression Frustration

S

Shawn B.

Greetings,

I'm using a custom WebBrowser control:
http://www.codeproject.com/KB/miscctrl/csEXWB.aspx


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
 
S

Shawn B.

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.ECMAScript |
RegexOptions.IgnoreCase);


Thanks,
Shawn
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top