Advertisement
Guest User

match some string

a guest
Mar 29th, 2012
27
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.43 KB | None | 0 0
  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://")]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement