Find a regular expression that matches the html format !! & Lt; ul & nbsp; id = "ul1" & gt; & nbsp; & lt; li & gt; 1 & lt;/li & gt; & nbsp; & nbsp; & lt; li & gt; 2 & lt;/li & gt; & lt;/ul & gt; can I use regular expressions to match such HTML code? I won't write a regular expression that matches the html format !!
1
2
Can I use regular expressions to match such HTML code? I won't write regular expressions. I went to the internet and read some basic tutorials. the matching results are only
Inside
No matching (the number of li in it is not fixed. it can be 2 or more ~). Please help write down the regular expression!
------ Solution --------------------
$str = 'afdasdfdsa
1
2
asdfasdfasd
3
4
fdsgsdfg';
preg_match_all('/
]*>.*<\/ul>/isU', $str, $matches);
print_r($matches[0]);
?>
------ Solution --------------------
$str = '
1
2
3
4
5
6
';
preg_match_all('/
.*?<\/ul>/s', $str, $matches);
var_dump($matches);