PDA

View Full Version : A little regular expression help


kobescoresagain
03-09-2006, 05:04 PM
$link_pattern = '/class="gSGRowEven">((.|\s)+?)<\/td>/';
preg_match_all($link_pattern, $roster[$i][$j], $link);



I need this to basically treat gSGRowEven and gSGRowOdd as the same. I thought I would just need to use | , but I think I am doing something wrong. Can someone tell me what I need to put there?

Trigunflame
03-10-2006, 11:18 AM
Eh pretty simple

$html = "
<table width='50%'>
<tr>
<td class='gSGRowEven'>
Testing1
</td>
<td class='gSGRowOdd'>
Testing2
</td>
<td class='gSGRowEven'>
Testing3
</td>
<td class='gSGRowMessedup'>
Testing4
</td>
</tr>
</table>
";

$regex = '#class=[\'"]gSGRow(?:Even|Odd)[\'"]>(.+)</td>#isU';
preg_match_all($regex, $html, $matches);
print_r($matches);