Find a regular expression that matches the html format !! & Lt; ul & nbsp; & gt; & nbsp; & lt; li & gt; 1 & lt; li & gt; & 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 regular expressions. I went to the internet and read some basic tutorials. the matching result is only a regular expression matching the html format !!
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
asdfasdfasd
fdsgsdfg';
preg_match_all('/
]*>.*<\/ul>/isU', $str, $matches);
print_r($matches[0]);
?>
------ Solution --------------------
$str = '
';
preg_match_all('/
.*?<\/ul>/s', $str, $matches);
var_dump($matches);