Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def find_date_type(string_date):
- import re
- group1 = re.findall("[0-9][0-9] - [a-zA-Z]",string_date)
- group11 = re.findall("[0-9][0-9]-[a-zA-Z]",string_date)
- group2 = re.findall("[0-9][0-9]/[0-9][0-9]",string_date)
- group22 = re.findall("[0-9][0-9] / [0-9][0-9]",string_date)
- group3 = re.findall("[a-zA-Z] - [a-zA-Z]", string_date)
- group33 = re.findall("[a-zA-Z]-[a-zA-Z]", string_date)
- if group1 or group11:
- group_type = 1
- elif group2 or group22:
- group_type = 2
- elif group3 or group33:
- group_type=3
- else:
- group_type=0
- return group_type
- #group1 = Jan 16-Febr 19
- #group11 = Jan 16 - Febr 19 (the dash has spaces)
- #group2 = 2011/2012
- #group22 = 2011 / 2012
- #group3 = June - July 2020
- #group33 = June-July 2020 (#no space in the dash)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement