Created
November 7, 2013 12:10
-
-
Save TheAnonymous/7353627 to your computer and use it in GitHub Desktop.
example Method to find a date in a text
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def find_dates text | |
twd = Array.new #twd = text with date | |
twd.concat text.scan(/[^\d](\d{1,2}[^\w\d ]\d{1,2}[^\w\d ]\d{4})/i) #26.03.1988 | |
twd.concat text.scan(/[^\d](\d{1,2}[^\w\d ]\d{1,2}[^\w\d ]\d{2})/i) #26.03.88 | |
twd.concat text.scan(/[^\d](\d{4}[^\w\d ]\d{1,2}[^\w\d ]\d{1,2})/i) #1988.03.26 | |
twd.concat text.scan(/[^\d](\d{2}[^\w\d ]\d{1,2}[^\w\d ]\d{1,2})/i) #88.03.26 | |
twd.concat text.scan(/(\d{1,2}.?(January|Januar|February|Februar|March|März|April|May|Mai|June|Juni|July|Juli|August|September|October|Oktober|November|December|Dezember)[^\w\d]\d{4})/i) | |
twd.concat text.scan(/(\d{1,2}.?(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)[^\w\d]\d{4})/i) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment