Page 1 of 1

Regular Expressions, stripping everything but letters, space

Posted: Fri Mar 31, 2006 10:44 pm
by ForgottenCreature
How do I go about removing everything in a string besides letters, spaces, and digits?

So far I have

$newvar = ereg_replace("[^A-Za-z0-9]", "", $string);

That takes care of the letters and digits, but not the spaces.

Help?

Posted: Sat Apr 01, 2006 2:32 am
by timvw
Have you already tried to add a simple ' ' to your list of characters? Probably want to lookup what \s shortcut does too.