very simple preg replace but I can’t think right.
I need to search for keywords such as: {this_is_a_key} and replace it with something else.
$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" ##//
so far this doesn’t work for me and I have tried a combination of () and [] but no luck
\w{1}means one “word character”. Try\w+or[^\}]+instead.Also, when using
\w, there’s no need for theimodifier.