note 21368 deleted from function.preg-replace by torben

From: Date: Fri, 10 May 2002 01:37:05 +0000
Subject: note 21368 deleted from function.preg-replace by torben
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-30412@lists.php.net to get a copy of this message
A little quirk I noted. I was trying to replace all instances of \ with \ and ran into the following problems: $Entry = preg_replace("/\\/", "\", $Entry); (this gave: Warning: No ending delimiter '/' found) $Entry = preg_replace("/(\\)/", "\", $Entry); (this gave: Warning: Compilation failed: missing ) at offset 3) $Entry = preg_replace("/[\\]/", "\", $Entry); (this gave: Warning: Compilation failed: missing terminating ] for character class at offset 3) For some reason, it escapes the ), ] or /... I finally got it to work when I did this: $Entry = preg_replace("/[(\\)]/", "\", $Entry); I don't know if anyone posted this before... I'm not all that fluent in PHP or regex, so please excuse any mistakes... (or if what I said seems glaringly obvious)

« previous php.notes (#30412) next »