What would be a good way to get rid of all chars except, letters, numbers, double quotes and hyphens. This is what I got so far.
$test = preg_replace('#[^a-zA-Z0-9"-]#',' ',$string);
Any suggestions?
Thanks
What would be a good way to get rid of all chars except, letters, numbers, double quotes and hyphens. This is what I got so far.
$test = preg_replace('#[^a-zA-Z0-9"-]#',' ',$string);
Any suggestions?
Thanks
Your regex is about as good a solution as you are going to find.
You can use \d to match digits, and the flag i to match a-z with case insensitivity.
$test = preg_replace('#[^a-z\d\w"-]#i','',$string);
Here is the php regex-syntax reference: http://se.php.net/manual/en/regexp.reference.php