Created
December 21, 2012 16:48
-
-
Save anonymous/4353957 to your computer and use it in GitHub Desktop.
Ruby RegEx text file processing - thanks to @ccharles and @jschumann for their help.
This file contains hidden or 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
| #Functions# {{{ | |
| def parseTeamName (line) | |
| teamName = /[[:alpha:]]*/.match(line) | |
| end | |
| def parseRecord (line) | |
| record = /[[:digit:]]*-[[:digit:]]/.match(line) | |
| end | |
| def parsePlayerName (line) | |
| playerName = /[[:digit:]][[:alpha:]]{2}(.*),/.match(line)[1].lstrip | |
| end | |
| def parsePosition (line) | |
| position = /,(.[[:alpha:]]*)/.match(line)[1].strip | |
| end | |
| def parsePoints (line) | |
| points = /.[[:digit:]]*$/.match(line).to_s.lstrip | |
| end | |
| def parseKicker (line) | |
| kicker = /:(.*)/.match(line)[1].lstrip | |
| end# }}} |
Nice work!
The camel casing isn't very Rubyish, though. Typically Rubyists use underscores. parse_team_name, etc.
See my fork. Can't do a pull request in gist, it seems.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I meant to create this in my account...hrmmm...