【发布时间】:2016-03-08 21:34:57
【问题描述】:
非常简单的 preg 替换,但我想不通。
我需要搜索关键字,例如:{this_is_a_key} 并替换为其他内容。
$text = 'this is a sentence with a {this_is_a_key} in it';
echo preg_replace('/\{\w{1}\}/i','keyword',$text);
//output should be
//## "this is a sentence with a keyword in it" ##//
到目前为止,这对我不起作用,我尝试了 () 和 [] 的组合,但没有运气
【问题讨论】:
标签: php regex preg-replace