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

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

WBOY
WBOYOriginal
2016-06-13 12:06:48826browse

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

本帖最后由 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);
Statement:
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