Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # regex from 1900-01-01 to 2099-12-31 -- somewhat valid
- import re
- string='<src="values"> from 1900-01-01 1900-00-01 1900-01-30 1900-01-31 1900-01-32 1800-01-01 \
- 19000101 1900 01 01 1900/01/01 1900.01.01 1900-19-01 1980-12-32 1900-00-18 2999-01-01 \
- 1900-01-01abc 1999-01-01 2100-01-01 to 2099-12-31'
- demo=re.findall('(?:19|20)\d\d-(?:[0][1-9]|[1][012])-(?:[0][1-9]|[12]\d|[3][01])',string)
- # >>> ['1900-01-01', '1900-01-30', '1900-01-31', '1900-01-01', '1999-01-01', '2099-12-31']
- print demo
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement