preg_replace() and backreferences

From: Date: Sun, 18 Nov 2001 16:46:52 +0000
Subject: preg_replace() and backreferences
Groups: php.dev 
Request: Send a blank email to php-dev+get-70820@lists.php.net to get a copy of this message
When trying to make a regular expression that escapes SQL wildcards a stumbled across this: <?php # Excpected result; "\%a\_" # Prints "\1a\1" echo preg_replace('/(%|_)/', '\\\1', '%a_'); ?> However, this snippet yields the correct result <?php echo preg_replace('/(%|_)/', '\\\\\1', '%a_'); ?> Am I missing something about regexps or is this a bug? regards, Marten.

« previous php.dev (#70820) next »