dimanche 23 août 2015

Regex - Pattern finds parts of itself with (.+)

In C#, I have the following Regex pattern (on an HTML string):

Regex TR = new Regex(@"<tr class=""(\w+)""  rel=""(\w+)"">(.+)</tr>");

The problem is, that when I run it, the match includes everything until the last </tr> occurrence in the HTML code. There are many <tr> tags in the code, so the (.+) pattern includes them and stops only in the last occurrence of </tr>.

I've tried using (\w+) instead, but it doesn't get certain characters inside the tags.

So how can I make this pattern stop at the first </tr>, and not go until the last one in the code?

Aucun commentaire:

Enregistrer un commentaire