Page 1 of 1

Regex to remove all special chars... EXCEPT spaces

Posted: Wed Jun 11, 2008 3:40 pm
by fluidbyte
I'm using a regular expression to remove all special characters from a string, however, I want to be able to leave spaces in the string, any ideas?

Code: Select all

 
preg_replace("/[^a-zA-Z0-9s]/", "", $pagTitle);
 

Re: Regex to remove all special chars... EXCEPT spaces

Posted: Wed Jun 11, 2008 3:56 pm
by fluidbyte
nevermind, I figured it out:

Code: Select all

 
preg_replace("/[^a-zA-Z0-9\s]/", "", $pagTitle);
 
Does anyone have a good regular expression reference for newbs?