开发者

regex (preg_match_all)

I can match this string {string} by using this regex : /{(.*)}/s in PHP's preg_replace_callback function.

But I don't what to match that string if that string is contained between tags like {tag}{/t开发者_开发问答ag},

For example :

I don't want to match {string} in {tag} Anything Here {string} Anything Here {/tag}.

Any suggestions (or maybe examples) are most welcome.


You can play with that :

preg_match_all("/(\{string\})|(\{tag\}.+\{.+tag\})/", $str, $m);

echo "<pre>";
print_r($m);
echo "</pre>";

As you will see, that expression will return a m with three array elements. The second array ellement contain all the {string} that are not into {tag}....{string}....{/tag}

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜