Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def which_date(text):
- usemdy = re.findall("<ref>[^<]+\|\s*date\s*=[^|]+\d+,?\s*\\d{4}", text)
- useymd = re.findall("<ref>[^<]+\|\s*date\s*=\s*\d{4}-\d{2}-\d{2}", text)
- usedmy = re.findall("<ref>[^<]+\|\s*date\s*=\s*\d+[^|]+\d{4}", text)
- if useymd >= usemdy and useymd >= usedmy: return 'useymd'
- if usemdy >= usedmy: return 'usemdy'
- return 'usedmy'
- t1 = 'Wikipedia text here<ref>{{cite web|title=test|date=Sept. 5, 2006}}</ref>'
- t2 = 'Text here<ref>{{cite web | date= 2006-04-01 | title=test}}</ref>'
- t3 = "Text here<ref>{{cite web | date = 5 September, 2005}}</ref>"
- >>> which_date(t1)
- 'usemdy'
- >>> which_date(t2)
- 'useymd'
- >>> which_date(t3)
- 'usedmy'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement