[thelist] Regex back reference problem.
Daniel Schlyder
daniel at bitblaze.com
Sun Dec 21 22:10:21 CST 2003
throwaway at gmontague.co.uk:
> So my question is this: How do I get php to distingush between $1 followed by
> '2nd' and $12 followed by 'nd'? Currently I'm kludging it by putting spaced
> into my replacement string ("\$1 $v$2") and post processing this space out but
> I'm sure there must be a more elegant solution.
You could add the 'e' option to the regexp to have PHP process the replacement
string as PHP code, and set it to
$replace_with = "'$1' . $v . '$2'";
Not sure if this is the best way, but at least you won't have to do any
post-processing.
Regards,
Daniel Schlyder
More information about the thelist
mailing list