Filter it. Use two re, one the one you've made, the other the double hyphen filter: pat2 = re.compile('.*?\-\-.*?') If the string matches this re, then the string is rejected, if it DOES NOT match (i.e. pat2.match('blah') returns None, i.e. if not pat2.match('blah')), then it is accepted. btw: You don't care about small letter?