Advertisement
here2share

# re_match_first_or_last_digits.py

Oct 10th, 2016
185
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.35 KB | None | 0 0
  1. # re_match_first_or_last_digits.py
  2.  
  3. import re
  4. url='ZZZZZ&h=749&hlZZZ&h=1200Z'
  5. z='&h=749&hl'
  6.  
  7. # ... for the first...
  8.  
  9. print re.findall('&h=([0-9]+).*',url)
  10.  
  11. # ... or the last...
  12.  
  13. print re.findall('.*&h=([0-9]+)',url)
  14.  
  15. # ... or if a unique delimiter is expected...
  16.  
  17. print re.findall('.*&h=([0-9]+)&',url)
  18.  
  19. # ... and if none found, [] is returned
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement