Advertisement
here2share

regex from 1900-01-01 to 2099-12-31 -- somewhat valid

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