Saturday, 17 August 2013

RegEx not correctly capturing data

RegEx not correctly capturing data

So I have the following code.
var filter = new Regex("(?<=description=\\\")(.+)(?=\\\">)");
return filter.Match(html).ToString();
The HTML data that regex is applied to:
<description="This chapter builds upon the information in part 1
("Introduction to Dynamic Equations")">
The result:
This Chapter builds upon the Information in part 1 (" Introduction=""
to="" Dynamic="" Equations="" ")
It seems that after the ' (" ' the regex tries to create key value pairs.
I've tried all the RegexOptions, but none of the options change the
behavior.

No comments:

Post a Comment