Modifying back reference on regular expression (PHP)

XiaoXiong

New Member
Getting frustrated...So, I want to modify the back reference of a preg_replace. Figured I can't actually modify (?) so am wondering if it's possible to change the regex to achieve same result.Example. Match \[code\][xx_xx]\[/code\] and output \[code\]"xx_xx"\[/code\] and \[code\]"xx xx"\[/code\]. The \[code\]"xx_xx"\[/code\] is straightforward (as follows) but the \[code\]"xx xx"\[/code\] ? \[code\]$y = "this [fishing_rod] is bent";echo preg_replace("/\[(.+?)\]/", "\"\\1\", $y);// this fishing_rod is bent\[/code\]How do I achieve : this fishing_rod fishing rod is bent ? (this is just an example, what I'm doing it is more complex !)
 
Back
Top