开发者

don't replace some occurrences using str_replace

I have a string like this "{text}...{text}...{text}...text..." I need to replace the "text" value in the string but only the ones that are not in curl开发者_StackOverflowy or square brackets


You should then use regular expressions :

/(?<!({|\[))text(?!(}|\]]))/

You can use this with preg_replace() :

preg_replace("/(?<!({|\[))text(?!(}|\]]))/", $replace, $string);
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜