How does php write a regular expression to retrieve the [attach] 1 [/attach] content [attach] 1 [/attach] Dashuai mansion [attach] 2 [/attach] & nbsp; how do you get the content between [attach] [/attach] 1 and 2., preg_match_all ('/[attach] (. *?) [/A php: how to write a regular expression to retrieve the content in [attach] 1 [/attach]
Content [attach] 1 [/attach] Dashuai Fu [attach] 2 [/attach] your
How to obtain the array of content 1 and 2 between [attach] [/attach]
------ Solution --------------------
Preg_match_all ('/[attach] (. *?) [/Attach]/I ',' [attach] 1 [/attach] [attach] 2 [/attach] ', $ out );
Print_r ($ out );
Not tested!
------ Solution --------------------
/[attach](.*?)[\/attach]/i
Just forgot to write the escape
------ Solution --------------------
Preg_match_all ('/\ [attach \] (. *?) \ [\/Attach \]/I ',' [attach] 1 [/attach] [attach] 2 [/attach] your ', $ out );
Print_r ($ out );
I want to test it for you!
------ Solution --------------------
The above arrays are all out, and the rest will be done by yourself.
------ Solution --------------------
$ Str = "content [attach] 1 [/attach] [attach] 2 [/attach] your ";
Preg_match_all ('/\ [attach] (. *?) \ [\/Attach]/I ', $ str, $ ret );
Print_r ($ ret [1]);
------ Solution --------------------
Output:
Array ([0] => 1 [1] => 2)
------ Solution --------------------
See http://clqwtt.blog.163.com/blog/static/22351105520139155735792/
You can also use php simple_html_dom implementation, refer to: http://clqwtt.blog.163.com/blog/static/223511055201391694845458/
------ Solution --------------------
Preg_match_all ('/\ [attach] ([^ \ [] *) \ [\/attach]/isU', $ str, $ ret );