note 42822 deleted from function.preg-replace by tomsommer

From: Date: Mon, 31 May 2004 00:19:18 +0000
Subject: note 42822 deleted from function.preg-replace by tomsommer
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-70324@lists.php.net to get a copy of this message
Note Submitter: Aaron Bockover ---- I'm working on a project that involves tokenizing content. Came up with this little regular expression that strips all leading and trailing non-alphanumeric characters from a string (but leaves "inner" non-alpha numeric characters). $result = preg_replace("/^[^[:alnum:]]+|[^[:alnum:]]+$/", "", $word); For instance: " **joe@email.com** " => "joe@email.com" " ... Phone: 555-555-1234." => "Phone: 555-555-1234" Hope someone finds it useful.

« previous php.notes (#70324) next »