daily pastebin goal
51%
SHARE
TWEET

Untitled

a guest Sep 15th, 2011 62 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. def which_date(text):
  2.     usemdy = re.findall("<ref>[^<]+\|\s*date\s*=[^|]+\d+,?\s*\\d{4}", text)
  3.     useymd = re.findall("<ref>[^<]+\|\s*date\s*=\s*\d{4}-\d{2}-\d{2}", text)
  4.     usedmy = re.findall("<ref>[^<]+\|\s*date\s*=\s*\d+[^|]+\d{4}", text)
  5.     if useymd >= usemdy and useymd >= usedmy: return 'useymd'
  6.     if usemdy >= usedmy: return 'usemdy'
  7.     return 'usedmy'
  8.  
  9. t1 = 'Wikipedia text here<ref>{{cite web|title=test|date=Sept. 5, 2006}}</ref>'
  10. t2 = 'Text here<ref>{{cite web | date= 2006-04-01 | title=test}}</ref>'
  11. t3 = "Text here<ref>{{cite web | date = 5 September, 2005}}</ref>"
  12. >>> which_date(t1)
  13. 'usemdy'
  14. >>> which_date(t2)
  15. 'useymd'
  16. >>> which_date(t3)
  17. 'usedmy'
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top