Posted by "Richard Lynch" on 01/20/06 00:17
On Tue, January 17, 2006 1:54 pm, Carl Furst wrote:
> Ok I am so stumped.. I'm doing something stupid and I can't figure it
> Here's the code:
> $eml = 'firstname.lastname@example.org
> if (strpos($eml, ' ')) echo "yep, there are spaces\n"; //does strpos
> see the
> 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
> to use preg_replace to get rid of them. Strpos sees the spaces and the
> echo statement is executed. The second echo prints nothing and the
> prints the original $eml with nothing substituted.
> Can anyone see why the perl reg isn't seeing the spaces?
It should "work"...
Though I would recommend using \\s instead of \s, because \ is a
special character to '' and when I see \s I think you mean something
like \n, only not...
[Reply to this message]