Php regular expression with div block $ a & lt; div; preg_match_all (& lt; div php regular expression with p Block
$ A ='
1
2
3
4
';
Preg_match_all ('/
(.*?) <\/P>/', $ a, $ match );
Echo'
';
Var_dump ($ match );
Could you tell me that the matching p on the Internet is written in this way, but when I write it, I find that he cannot completely match a p block! For example, my p id = css, his end/p is behind 3, but this write can only end at 2. is there any way to match his own p block?
------ Solution --------------------
Http://downloads.sourceforge.net/project/simplehtmldom/simplehtmldom/1.5/simplehtmldom_1_5.zip? R = http % 3A % 2F % 2Fsourceforge.net % 2 Fprojects % 2 Fsimplehtmldom % 2 Ffiles % 2F & ts = 1332749181 & use_mirror = nchc
Simplehtmldom class
Simple, practical, and efficient
You do not need to play with regular expressions on your own.
------ Solution --------------------
Nested tags are recursively matched.
PHP code
12
34
'; $ Pattern = '#
] *> ([^ <>] * | (? R ))*)
] *> # '; Preg_match_all ($ pattern, $ str, $ matches); echo $ matches [0] [0]; //
1
2
3
------ Solution --------------------
Discussion
Well, what's the solution? if it's a page code and we want to remove p from the header and tail, what's the best solution?