Thanks a lot...Strange to me, because I am working with regular expressions for a long time, but I can not read your regex code and apply it to my real project! Can you help me with that? Here goes the real project:
String:
Code:
td>team1</td>
<td><img src='/img/b.png' class='redYellowCard' alt='' \> team2</td>
<td><img src='/img/b.png' class='redYellowCard' alt='' \> <img src='/img/b.png' class='redCard' alt='' \> team3</td>
Array needed:
Code:
Array
(
// the whole matches
[0] => Array
(
[0] => team1
[1] => <img src='/img/b.png' class='redYellowCard' alt='' \> team2
[2] => <img src='/img/b.png' class='redYellowCard' alt='' \> <img src='/img/b.png' class='redCard' alt='' \> team3
)
//the images independently of their number - 0, 1, 2, 3 etc. For the simple expample, I give the maximum of 2
[1] => Array
(
[0] =>
[1] => <img src='/img/b.png' class='redYellowCard' alt='' \>
[2] => <img src='/img/b.png' class='redYellowCard' alt='' \> <img src='/img/b.png' class='redCard' alt='' \>
)
//the teams
[2] => Array
(
[0] => team1
[1] => team2
[2] => team3
)
)
I was using that code trying to get it:
Code:
preg_match_all(
"#" . "(<[a-z][a-z0-9]*[^<>]*>)" . "([[:space:]]*\<img src='/img/b.png' class\='[redYlowCard]+' alt\='' /\>[[:space:]]*)*" . "([a-z0-9]+)" . "(</[a-z][a-z0-9]*[^<>]*>)"
)
but it was matching MAXIMUM one image!
I would really appreciate if you help me to apply your code to that project.