I have an uploader in my web page, but some people upload files named like "compañia 15% *09.jpg" and i have problems when the filenames are like that one.
I would like to found a class that returns for that example something like this: "compania1509.jpg".
In other words, you'd like to get rid of all characters outside the printable ASCII range? You can use
String#replaceAll()
with a pattern of[^\x20-\x7e]
for this.If you want to get rid of spaces as well, then start with
\x21
instead. You can even restrict it to Word-characters only. Use\W
to indicate "any non-word" character. The name will then match only alphanumericals and the underscore.