RE: [PHP] Extra spaces added by ereg_replace

From: Date: Tue, 25 Jul 2000 23:12:44 +0000
Subject: RE: [PHP] Extra spaces added by ereg_replace
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-8160@lists.php.net to get a copy of this message
Hmm.. I can't seem to replicate your bug in PHP4.. maybe you should upgrade or try using preg_replace(). <? $string = "This is a test"; echo "'", ereg_replace( " is", " was", $string ), "'<br>\n"; echo "'", ereg_replace( "( )is", "\\1was", $string ), "'<br>\n"; echo "'", ereg_replace( "(( )is)", "\\2was", $string ), "'<br>\n"; ?> yields 'This was a test'<br> 'This was a test'<br> 'This was a test'<br> -----Original Message----- > Whenever the output from ereg_replace and eregi_replace comes back, it > has an extra space on either side of whatever the output was. Now, this > doesn't matter if the output was displayed in a browser, but for an edit > function in a bulletin board (where the text was displayed back in a > textarea) it is painfully obvious.

« previous php.general (#8160) next »