Created
June 12, 2014 06:04
-
-
Save plexus/9a9ee2e00a4f80f826a1 to your computer and use it in GitHub Desktop.
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
# -*- coding: utf-8 -*- | |
require 'open-uri' | |
#txt = open('https://raw.githubusercontent.com/openfootball/world-cup/master/2014--brazil/cup.txt').read | |
txt = open('https://raw.githubusercontent.com/openfootball/world-cup/master/2010--south-africa/cup.txt').read | |
# (1) Fri Jun/11 16:00 South Africa 1-1 Mexico @ Soccer City, Johannesburg | |
# (1) Thu Jun/12 17:00 Brazil - Croatia @ Arena de São Paulo, São Paulo (UTC-3) | |
regex = %r{ | |
\( (?<number> \d+ ) \) \s+ | |
(?<day_of_week> \w+ ) \s+ | |
(?<month> \w+ ) / | |
(?<day_of_month> \d+ ) \s+ | |
(?<hour> \d+ ) : | |
(?<minute> \d+ ) \s+ | |
(?<team_a> \w+ ) \s+ | |
( (?<score_a> \d+) )? \s*-\s* | |
( (?<score_b> \d+) )? \s+ | |
(?<team_b> \w+ ) \s*@\s* | |
(?<location> .*) | |
(\(UTC(?<utc_offset>[+-]\d+)\))? | |
}x | |
txt.each_line do |line| | |
m = regex.match(line) | |
p m if m | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment