Reputation: 179
Hi I'm new to regex so could anyone help me? I want to remove all illegal characters in a filename for windows. This is the regex I used
(/[^a-zA-Z ')' 0-9\\-]+/g,'')")
The problem is it's not getting rid of the brackets. For example the original filename was
[Yuubin Basha (Akizuki Ryou)] Cheap Thrill (Final Fantasy VII) [English] [Dragonfly]
and it renames to
Yuubin Basha Akizuki Ryou) Cheap Thrill Final Fantasy VII) English Dragonfly
It doesn't remove all the brackets. Can anyone help me fix my regex?
Upvotes: 0
Views: 968
Reputation: 354694
File names on Windows can contain all Unicode characters except U+0000 through U+001F and :?*"\/<>|
. So you can use
[\x00-\x1f:?\\/*"<>|]
But there are other considerations as well, e.g. a file name cannot end with a space.
Upvotes: 5
Reputation: 12296
/[^a-zA-Z\\)\\(\\]\\[0-9\\-\s]+/g
regex should look like in your case
Upvotes: 1