Regular Expression repetition of class

Posted by codersarepeople on Stack Overflow See other posts from Stack Overflow or by codersarepeople
Published on 2011-11-29T00:48:58Z Indexed on 2011/11/29 1:50 UTC
Read the original article Hit count: 147

Filed under:
|

I am trying to figure out a regular expression for the following:

<tr class="A">.*</tr><tr class="(B|C)">.*</tr>

Now The second tr class will repeat an unknown number of times, with something unknown in between repetitions, but simply putting it in parentheses and added a plus doesn't work.

Here's the PHP code that didn't work:

$pattern = '/<tr\ class=\"A\">.*(<tr\ class=\"(B|C)\">.*<\/tr>.*)+/';
preg_match_all($pattern,$playerHtml,$scores);

But it only returns the first

Here's an example of something that should match:

<tr class="A">blah</tr>blah
<tr class="B">blah</tr>blah
<tr class="B">blah</tr>blah
<tr class="C">blah</tr>

This only matches blahblahblah

© Stack Overflow or respective owner

Related posts about php

Related posts about regex