Re: preg_replace

From: Date: Fri, 05 Jun 2009 08:29:01 +0000
Subject: Re: preg_replace
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-293651@lists.php.net to get a copy of this message
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:biprellim@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

« previous php.general (#293651) next »