Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

match some string

By: a guest on Mar 29th, 2012  |  syntax: None  |  size: 0.43 KB  |  views: 14  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. >>> re.match('(?!http://).*\.asp', 'http://foo.asp')
  2. >>> re.match('(?!http://).*\.asp', 'foo.asp')
  3. <_sre.SRE_Match object at 0x7f34f8432920>
  4.        
  5. >>> re.match('[^/]*.asp', '/tmp/foo.asp')
  6. >>> re.match('[^/]*.asp', 'http://foo.asp')
  7. >>> re.match('[^/]*.asp', 'ftp://foo.asp')
  8. >>> re.match('[^/]*.asp', 'foo.asp')
  9. <_sre.SRE_Match object at 0x2abe856856b0>
  10.        
  11. [s for s in list_of_strings if s.endswith(".asp") and not s.startswith("http://")]