Consider the following string:
$text = "Dat foo 13.45 and $600 bar {70} and {8}";
I need to label all numbers in $text, except for when they are between curly braces. I now have this:
echo preg_replace("([0-9]+(?:\.[0-9]+)?)","{NUMBER:$0}",$tweet);
which outputs:
Dat foo {NUMBER:13.45} and ${NUMBER:600} bar {{NUMBER:70}} and {{NUMBER:8}}
However, the desired output is:
Dat foo {NUMBER:13.45} and ${NUMBER:600} bar {70} and {8}
where numbers between { and } are ignored. Is it possible to expand the regex to ommit curly braces or is another solution needed here?
Any help would be greatly appreciated :-)