mysql - I didn't understand Regex on PHP. -


i trying clean special characters string regex code, far have did code

$data = preg_replace('/[^a-za-z0-9]/s', '', $nickname);  

but code cleans including spaces, want allow space , - sign on string, should add in there? sorry if easy question english not , couldn't find resources in main language. me that?

$data = preg_replace('/[^a-za-z0-9 -]/s', '', $nickname);

[^a-za-z0-9 .-] 

regular expression visualization

debuggex demo


Comments