I've got a long set of replace statements to get rid of the following characters in filenames (from the C# source code):
RealInvalidPathChars = { '\"', '<', '>', '|', '\0', (Char)1, (Char)2, (Char)3, (Char)4, (Char)5,
(Char)6, (Char)7, (Char)8, (Char)9, (Char)10, (Char)11, (Char)12, (Char)13, (Char)14, (Char)15,
(Char)16, (Char)17, (Char)18, (Char)19, (Char)20, (Char)21, (Char)22, (Char)23, (Char)24, (Char)25,
(Char)26, (Char)27, (Char)28, (Char)29, (Char)30, (Char)31 };
The "dumb" JS looks like this:
var r = s.replace('\u0001','_').replace('\u0002', '_') ....etc...;
Is there a JS way to iteratively replace these special characters in a loop? Or is there a regex can be used to deal with the '\u00xx'
characters (I've never seen this done)? The first character in this C#-defined range is '\u0001'
and the last is '\u001f'
.