SHARE
TWEET

match some string

a guest Mar 29th, 2012 14 Never
  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://")]
RAW Paste Data
Top