Hey Ben,

to replace everything thats not alphanumeric, use the following statement:

$output = preg_replace('/[^[:alnum:]]/', '', $input);

Greetings from Germany

Marc

PS: Spaces are not alphanumeric ;)


Ben Miller wrote:
Oh yeah - not sure if spaces are considered alphanumeric or not, but I need
to keep spaces - replacing anything that is NOT a letter, a number or a
space.  Thanks again.

-----Original Message-----
From: Ben Miller [mailto:biprel...@gmail.com] Sent: Friday, June 05, 2009 2:09 AM
To: php-general@lists.php.net
Subject: [PHP] preg_replace

I bought PHP & MySQL for DUMMIES and it shows me how to use special characters for pattern matching and I've figured out the basics of using preg_replace to replace pattern matches. What I am having trouble with, though, is figuring out how to replace anything that does not match the pattern. For example, I want to replace anything that is NOT an alphanumeric character. Any help would be appreciated. Thanks.

Ben



--
Synchronize and share your files over the web for free
http://bithub.net/

My Twitter feed
http://twitter.com/MarcSteinert





--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to