Home > Backend Development > PHP Tutorial > 这个正则该如何写?高手来帮帮忙

这个正则该如何写?高手来帮帮忙

WBOY
Release: 2016-06-13 12:06:48
Original
823 people have browsed it

这个正则该怎么写?高手来帮帮忙

本帖最后由 xjl756425616 于 2014-09-11 16:26:36 编辑
------解决思路----------------------

$str = "[size=18px]123[size=16px]456[/size]789[/size]";

preg_match_all('#\[size=[^\[\]]+\](?:[^\[\]]+
------解决思路----------------------
((?R)))*\[/size\]#', $str, $matchs);

print_r($matchs);
------解决思路----------------------
别小看我这么写,答案正是你想要的
$str = "<span   style="max-width:90%">123[size=16px]456</span>789[/size]";<br /><br />$pattern = '/\[size=18px\]123(.*?)789\[\/size\]/';<br /><br />preg_match_all($pattern, $str, $arr);<br /><br />print_r($arr);
Copy after login
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template