Created
May 28, 2014 04:27
-
-
Save ross-spencer/5e759a65d3928c64a63d to your computer and use it in GitHub Desktop.
Draft regular expressions for detecting invalid Microsoft file names [Python]
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Based on: http://msdn.microsoft.com/en-us/library/aa365247(VS.85).aspx | |
#regex strings... | |
#CON|PRN|AUX|NUL | |
msdn_bad_names_one = "(^)(con|prn|aux|nul)($|.|.[0-9a-zA-Z]{1,5}$)" # badname + extension | |
#COM1-COM9 | LPT1-LPT9 | |
msdn_bad_names_two = "((^)(COM|LPT)(.*[1-9]))($|(.[0-9a-zA-Z]{0,5}))" # badname + extension | |
#<, >, :, ", /, \, ?, *, |, \x00-\x1f | |
non_recommended_chars = '(<|>|:|"|/|\\|\?|\*|\||\x00-\x1f)' | |
#[] | |
square_brackets = '(\[|\])' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment