I need to remove all special characters from string except - ( )
I have this code so far
$q = preg_replace('/[^A-Za-z0-9\-]/', '', $q); //removes ALL characters
how to exclude - ( )
?
I need to remove all special characters from string except - ( )
I have this code so far
$q = preg_replace('/[^A-Za-z0-9\-]/', '', $q); //removes ALL characters
how to exclude - ( )
?
You should try something like
$q = preg_replace('/[^A-Za-z0-9\-\(\) ]/', '', $q); //removes ALL characters
The above will allow spaces
, (
, )
as well as -
.