I want to clear the file names of all downloaded files. I want to delete all characters except periods, letters and numbers. I am not very familiar with regex, so I decided to ask here. Can someone point me to a useful site or show me how to do this? I am using PHP.
$newfilename=preg_replace('/[^a-zA-Z0-9.]/','',$filename);
s/[^.a-zA-Z\d]//g
(This is a Perl expression of how to use RegExp. In PHP, you do:
$output = preg_replace('/[^.a-zA-Z\d]/', '', $input);
Try using this:
$cleanString = preg_replace('#\W#', '', $string);
It will delete everything except letters and numbers.