php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #12140 pcre_replace change behavior with \
Submitted: 2001-07-13 08:51 UTC Modified: 2001-08-06 12:58 UTC
From: madmax at express dot ru Assigned:
Status: Closed Package: PCRE related
PHP Version: 4.0.6 OS:
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: madmax at express dot ru
New email:
PHP Version: OS:

 

 [2001-07-13 08:51 UTC] madmax at express dot ru
task: 
need replace \ (one) to \\\\ (four)

On php.4.0.5 work:
$val1=preg_replace('/\\\/',"\\\\\\\\",$val);

On php 4.0.6 work:
$val1=preg_replace('/\\\/',"\\\\\\\\\\\\\\\\",$val);

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-08-06 12:58 UTC] andrei@php.net
That's right. Your  \\\\\\\\ turns into \\\\ by the time PHP string parsing is done with it. Then the extension looks at it and sees two escaped backslashes so that's what you get - two backslashes.

In general, use str_replace() for things like that.
 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Wed Mar 20 15:01:27 2019 UTC