P
Pete Davis
I'm using regular expressions to extract some data and some links from some
web pages. I download the page and then I want to get a list of certain
links.
For building regular expressions, I use an app call The Regulator, which
makes it pretty easy to build and test regular expressions.
As a warning, I'm real weak with regular expressions. Let's say my regular
expression is:
(href=)(?<caturl>.*)(class=title>\[  
Now, using The Regulator and giving it the source for a particular web page,
I get 8 matches.
According to the regulator, the options it's using are:
Multiline, ignore case, ignore whitespace
In my own code, I'm doing:
Regex indexRegex = new Regex(categoryListRegex,
RegexOptions.Multiline |
RegexOptions.IgnorePatternWhitespace |
RegexOptions.IgnoreCase);
MatchCollection indexMatches = indexRegex.Matches(pageText);
This only returns one match in indexMatches with the same page that I'm
giving The Regulator. It seems that no matter what combination of regex
options I use, I'm only getting one match.
Why is that? How do I get all 8 matches?
Thanks.
pete
web pages. I download the page and then I want to get a list of certain
links.
For building regular expressions, I use an app call The Regulator, which
makes it pretty easy to build and test regular expressions.
As a warning, I'm real weak with regular expressions. Let's say my regular
expression is:
(href=)(?<caturl>.*)(class=title>\[  
Now, using The Regulator and giving it the source for a particular web page,
I get 8 matches.
According to the regulator, the options it's using are:
Multiline, ignore case, ignore whitespace
In my own code, I'm doing:
Regex indexRegex = new Regex(categoryListRegex,
RegexOptions.Multiline |
RegexOptions.IgnorePatternWhitespace |
RegexOptions.IgnoreCase);
MatchCollection indexMatches = indexRegex.Matches(pageText);
This only returns one match in indexMatches with the same page that I'm
giving The Regulator. It seems that no matter what combination of regex
options I use, I'm only getting one match.
Why is that? How do I get all 8 matches?
Thanks.
pete