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

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

WBOY
Release: 2016-06-23 13:48:59
Original
1045 people have browsed it


回复讨论(解决方案)


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

preg_match_all('#\[size=[^\[\]]+\](?:[^\[\]]+|((?R)))*\[/size\]#', $str, $matchs);

print_r($matchs);


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

preg_match_all('#\[size=[^\[\]]+\](?:[^\[\]]+|((?R)))*\[/size\]#', $str, $matchs);

print_r($matchs);



大神!!!太牛了,需要点时间消化一下



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

preg_match_all('#\[size=[^\[\]]+\](?:[^\[\]]+|((?R)))*\[/size\]#', $str, $matchs);

print_r($matchs);



大神!!!太牛了,需要点时间消化一下



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

preg_match_all('#\[size=[^\[\]]+\](?:[^\[\]]+|((?R)))*\[/size\]#', $str, $matchs);

print_r($matchs);



大神!!!太牛了,需要点时间消化一下 灌水。。

别小看我这么写,答案正是你想要的

$str = "123[size=16px]456789[/size]";$pattern = '/\[size=18px\]123(.*?)789\[\/size\]/';preg_match_all($pattern, $str, $arr);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