Forum Moderators: coopster
I admit I am terrible at regex. I have some pages with a bunch of text, within which includes:
top:1234
top:1244
top:1264
etc
I would like to subtract 1000 from all the numbers associated with "top:" only, and no other numbers.
Here is my (bad) regex attempt, but alas, it does not seem to work...any ideas?
$content = preg_replace("/top:([0-9]*)$1/i",${1} - 1000,$content);
Any help greatly appreciated.
The e modifier makes preg_replace [php.net] treat the replacement parameter as PHP code after the appropriate references substitution is done.
;)
$content = preg_replace("/top:([0-9]+)/e", "\$1 - 1000", $content);