我有这个小代码来捕获括号之间的文本:
$string = '[title=my title] http://bit.ly/gANFxi [maps:some cool place]';
preg_match_all('/\[([^\]]*)\]/', $string, $matches);
print_($matches[0]);
我得到的是以下内容:
大批( [0] => [标题=我的标题] [1] => [地图:一些很酷的地方] )
我想更严格地避免“[some-not cool]”或“[another+stuff]”,所以我只需要捕获 [some:thing] 和 [some=thing]。
我该怎么做?