Evaluate a regular expression! & Lt; ul & nbsp; id = "a" & gt; & lt; li & nbsp; style = "display: none" & gt; xxx & lt; /li & gt; & lt; li & nbsp; style = "display: block" & gt; xxx & lt;/li & gt; & lt; li & gt; xxx & lt;/li & calculates a regular expression!
Xxx
Xxx
Xxx
Xxx
Xxx
Xxx
I want to obtain the contents of every li in UL with ID B in the regular expression. how should I write the regular expression?
/ .*? (.*?) <\/Li> .*? <\/Ul>/is can only match the content in the first li to share: Xxx Xxx
Xxx
------ Solution --------------------
$s=<<
xxx
Xxx
Xxx
Xxx
Xxx
Xxx
Html;
Preg_match ('# (. +)# Is ', $ s, $ m );
Preg_match_all ('# ] *> (. +)# IsU ', $ m [1], $ arr );
Print_r ($ arr [1]);
------ Solution --------------------
(? <= (? : \ S * .*? <\/Li> \ s *) \ s * (.*?) <\/Li> \ s * to give you a reference. you can modify it as needed.