Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # re_match_first_or_last_digits.py
- import re
- url='ZZZZZ&h=749&hlZZZ&h=1200Z'
- z='&h=749&hl'
- # ... for the first...
- print re.findall('&h=([0-9]+).*',url)
- # ... or the last...
- print re.findall('.*&h=([0-9]+)',url)
- # ... or if a unique delimiter is expected...
- print re.findall('.*&h=([0-9]+)&',url)
- # ... and if none found, [] is returned
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement