Not sure why but the behaviour is strange. Whenever I use the \u0000 in the regular expression, it then matches nothing.
var regexpNotWorking:RegExp = new RegExp("[^\u0000-\u0020]");
var regexpWorking:RegExp = new RegExp("[^\u0001-\u0020]");
var input:String = "I should be valid";
trace("not working: " + input.match(regexpNotWorking));
trace("working: " + input.match(regexpWorking));
the output are:
not working: null
working: I
Anyone has idea why \u0001 is working, but \u0000 is not?
How could I make sure the input does not contain \u0000?
Why not remove the negation and change the regular expression to this:
BTW no need to use new RegExp or quotes around regular expressions in Flex.
But that’s probably not quite the answer you are looking for. Here’s one way to find if a string contains a NUL character.
To check if any characters are in the range \u0000 to \u0020 you can do this: