Skip to content

Instantly share code, notes, and snippets.

Created December 21, 2012 16:48
Show Gist options
  • Select an option

  • Save anonymous/4353957 to your computer and use it in GitHub Desktop.

Select an option

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.
#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# }}}
@inseaner
Copy link

I meant to create this in my account...hrmmm...

@jschumann
Copy link

Nice work!

The camel casing isn't very Rubyish, though. Typically Rubyists use underscores. parse_team_name, etc.

@jschumann
Copy link

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