Regular Expression repetition of class
- by codersarepeople
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