note 2668 deleted from function.ereg-replace by jimw

From: Date: Fri, 02 Nov 2001 01:41:36 +0000
Subject: note 2668 deleted from function.ereg-replace by jimw
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-20173@lists.php.net to get a copy of this message
When trying to represent a literal backslash in a regexp, your source code needs to contain *four* contiguous backslashes (which become two actual backslashes once your double-quoted string is parsed). Example: <pre>$footer = ereg_replace("\\\\\"", "\"", $footer);</pre> This is unexpected, because it's different from the standard set by Perl -- although Perl would probably be the same way if a regexp were being specified in a string instead of in the // construct. [Ed. note-This has nothing to do with regexps per se. If you use single-quoted strings, you will find that you need only the same number of backslashes as you did in perl. When using double-quoted strings, the extra slashes are needed to prevent PHP from interpolating the sequence before passing it to the regexp engine.]

« previous php.notes (#20173) next »