note 40791 added to function.preg-replace

From: Date: Mon, 15 Mar 2004 05:54:50 +0000
Subject: note 40791 added to function.preg-replace
Groups: php.notes 
Request: Send a blank email to php-notes+get-66840@lists.php.net to get a copy of this message
For all the people out there that don't understand a single bit of this regular expression replacement stuff (including myself), and just want to take a string and remove all special characters from it, leaving it with only spaces, underscores, letters, and numbers...here is the code! $string = preg_replace('/[^\w\s\-]/','',$string); To tell you the truth, I don't completely understand it but I did some research and mixed perl with php and it works and that's all that matters. ---- Manual Page -- http://www.php.net/manual/en/function.preg-replace.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+40791 Delete -- http://master.php.net/manage/user-notes.php?action=delete+40791&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+40791&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#66840) next »