-4
$string = '[url=http://domain.com]My Webpage[/url][img]http://domain.com/image1.jpg[/img][center][img]http://domain.com/image2.gif[/img][/center][center][thumb]http://domain.com/image3.png[/thumb][/center]';
preg_match_all('/.*?\[img|thumb\](http.+?)\[\/.*+/', $string, $matches);
var_dump($matches);

试图获取图像数组(image1.jpg、image2.gif、image3.png)。图像可能介于[img][\img]和之间[thumb][\thumb]。而且我还需要检查一整行[center][thumb]http://domain.com/image3.png[/thumb][/center]以将其更改为其他图像。有人可以帮忙吗?

4

1 回答 1

2

以下模式将其全部提取出来。

@\[(img|thumb)\](.+?)\[/\\1@

爱迪生

于 2013-01-12T14:57:46.980 回答