I have the string page-24
and want to replace 24
by any other number.
The script is written in PHP and uses preg_replace
, however this problem should be independent from the programming language.
My match pattern is: (.*-)(\d*)
The replace pattern would be: $1[insert number here]$2
The backreferences work, but I cannot insert a number into the given place in the replace pattern because the expression would be interpreted in a wrong way. (First backreference to 199th match, if I inserted 99 as number.)
Am I missing an escape character here?