not sure why this passes: >>> regex = r'[A-Za-z]:\\([^/:\*\?"<>\|])*' >>> p = re.compile(regex) >>> p.match('c:\\test') <_sre.SRE_Match object at 0x009D77E0> >>> p.match('c:\\test?:/') <_sre.SRE_Match object at 0x009D7720> >>> the last example shouldnt give a match