Consider the following:
$string = "A string with {LABELS} and {more|232} {lbls} and some other stuff";
echo str_replace('/(\{.*?\})/', '', $string);
I’m trying to remove all labels (a label is any text between {brackets}). The expected output was:
A string with and and some other stuff
But what I get was the original string:
A string with {LABELS} and {more|232} {lbls} and some other stuff
What am I doing wrong?
str_replace doesnt work with regular expressions, use preg_replace instead:
http://php.net/manual/en/function.preg-replace.php