I'm dealing with a program that will have the user typing into a entry widget, then the name will be checked to see if it is valid. If it is, the file gets renamed, if not, [something else happens].
For now, I'm dealing only with the windows naming rules. I got them from this question.
My problem is with the "0-31 (ASCII control characters)". I understand that they are control characters used to deal with hardware and are not allowed in a file name.
But how am I supposed to check for them?
This website has a table of them. And I could use ord() in each char of the string to look for a value in the 0-31 range. But I'm trying to use (and learn) a bit more of regex, and would like to resolve the issue by using it.
I tried using [\x00-\x31], but it didn't work since the unicode sequence for the 0-31 chars are different.
I tried using \\[t|n|r|x]\d?\d?[a-z]? and it did work for the 0-31 numbers after I ran chr(ord(char)) on them. But this goes back to checking each char individually.
I know that I could just cast the string to os.rename() and catch the error, but I would like to avoid doing it.
I would like to use only things that are already built-in python if possible.
\u0080-\u009F)