[pmwiki-devel] help with preg_replace()

Patrick R. Michaud pmichaud at pobox.com
Thu Mar 15 12:20:37 CDT 2007


On Thu, Mar 15, 2007 at 11:39:35AM -0500, Ben Stallings wrote:
> Regular expressions make my eyes cross.  Can someone help me with this 
> puzzle?
> 
> I want to take a string and replace all occurrences of [var] (i.e. any 
> single word enclosed in single brackets) with DQquote($_REQUEST['var']) 
> (i.e. any post, get, or cookie data with that variable name, passed 
> through a function called DQquote).

    $new = preg_replace('/\\[(\\w+)\\]/e', 'DQquote($_REQUEST["$1"])', $old);

Pm



More information about the pmwiki-devel mailing list