I want to replace all characters except 'A-Z','a-z','0-9', '_', '-', '(', ')' from a filename, until the extension.
For the moment i have:
$filename = '23$%^&.234234.%^.234$%$#)(.^$.png';
$fileName = preg_replace('/[^A-Za-z0-9_\-\(\) ]/', '-', $filename);
and i get
$filename : 23------234234----234----)(----png
The problem is that the '.' from extension is removed. The filename can have different extension.
How should i make to change the characters, but not the extension.