Re: Help with regular expressions

From: Date: Tue, 17 Jan 2006 20:10:34 +0000
Subject: Re: Help with regular expressions
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-228728@lists.php.net to get a copy of this message
Carl Furst wrote:
Ok I am so stumped.. I'm doing something stupid and I can't figure it out.. Here's the code: <?php
$eml = 'hiddenemailadddress@hiddendomain.net                        ceo';
if (strpos($eml, ' ')) echo "yep, there are spaces\n"; //does strpos see the spaces? echo preg_replace('/\s/', '', $eml); //WTF? Preg_replace does not? echo "$eml\n"; ?> As you can see there are a bunch of spaces in that email address. I'm trying to use preg_replace to get rid of them. Strpos sees the spaces and the first echo statement is executed. The second echo prints nothing and the third prints the original $eml with nothing substituted. Can anyone see why the perl reg isn't seeing the spaces? Carl
Working fine on my end (copy/pasted your code) -- John C. Nichel IV Programmer/System Admin (ÜberGeek) Dot Com Holdings of Buffalo 716.856.9675 jnichel@dotcomholdingsofbuffalo.com

« previous php.general (#228728) next »