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

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

WBOY
WBOYOriginal
2016-06-23 13:48:59993browse


回复讨论(解决方案)


$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);

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