php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #27705 Error in eregi_replace(...)
Submitted: 2004-03-25 15:51 UTC Modified: 2004-03-25 15:54 UTC
From: bartwared2 at planet dot nl Assigned:
Status: Not a bug Package: Unknown/Other Function
PHP Version: 4.3.4 OS: Linux, apache 1.3.29
Private report: No CVE-ID: None
 [2004-03-25 15:51 UTC] bartwared2 at planet dot nl
Description:
------------
I have been trying to get the  eregi_replace  function to remove \\ from my string. I have also tried ereg_replace. Every time I try to it fails. This *is* a bug.In http://bugs.php.net/bug.php?id=26524 was said that it isn't, but I'm sure it is.

We all know, to print a \ on the screen we can use this:
 print("\\");

This works, ofcourse. Try it.
But when you try to use eregi_replace to replace a \, it will give the following error: 

Warning: eregi_replace(): REG_EESCAPE in /where-ever.php on line 5

There is nothing diffrent from my host to any others, and more people have this problem, I think.

Try this:

<?php
    $description = "Hi, \\how are you?";
    $description = eregi_replace("\\", " ", $description);
?>

Reproduce code:
---------------
$description = "Hi, \\how are you?";
$description = eregi_replace("\\", " ", $description);

Expected result:
----------------
I expected $description to become "Hi,  how are you", but instead of that I got...

Actual result:
--------------
Warning: eregi_replace(): REG_EESCAPE in /home/bartware/public_html/bart-ware.com/admin.php on line 188

Line 188 is: $description = eregi_replace("\\", " ", $description);

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-03-25 15:54 UTC] iliaa@php.net
Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system is not the
appropriate forum for asking support questions. 

Thank you for your interest in PHP.

You need to use \\\\ instead of \\.  
 
PHP Copyright © 2001-2026 The PHP Group
All rights reserved.
Last updated: Fri Feb 06 03:00:02 2026 UTC