Regular Expression Matching nested div, evaluate PHP implementation ~ The following html string: $ str & nbsp; & lt; div & nbsp; & gt; & nbsp; & lt; div & nbsp; & gt; 1111111111 & lt; div & gt; & nbsp; & regular match nested p, evaluate PHP implementation ~
The following html string:
$ Str ='
1111111111
2222222222
Link1
1111111111
2222222222
';
Results to be matched:
Set
The content in is matched:
1 =>
1111111111
2222222222
Link1
2 =>
1111111111
2222222222
Php program implementation, online, etc ~
------ Solution --------------------
Reference:
$ Patten = '/(
(*)
)/';
Preg_match_all ($ patten, $ str, $ match );
It's not that simple, because there will be multiple
, You should start from the inner layer, and then layer by layer to know that
So Far
------ Solution --------------------
$ Str ='
1111111111
2222222222
Link1
1111111111
2222222222
';
If (preg_match_all ('#
] *> (?> [^
] +
------ Solution --------------------
. +?
------ Solution --------------------
------ Solution --------------------
(? R ))*)
# Is ', $ str, $ matches )){
Print_r ($ matches );
}
?>