>>> re.match('(?!http://).*\.asp', 'http://foo.asp') >>> re.match('(?!http://).*\.asp', 'foo.asp') <_sre.SRE_Match object at 0x7f34f8432920> >>> re.match('[^/]*.asp', '/tmp/foo.asp') >>> re.match('[^/]*.asp', 'http://foo.asp') >>> re.match('[^/]*.asp', 'ftp://foo.asp') >>> re.match('[^/]*.asp', 'foo.asp') <_sre.SRE_Match object at 0x2abe856856b0> [s for s in list_of_strings if s.endswith(".asp") and not s.startswith("http://")]