Skip to content

Instantly share code, notes, and snippets.

@ahoward
Created October 30, 2010 17:23
Show Gist options
  • Save ahoward/655544 to your computer and use it in GitHub Desktop.
Save ahoward/655544 to your computer and use it in GitHub Desktop.
re = / ^ (foo) (bar) $ /iox
match, foo, bar = re.match('FOOBAR').to_a
if match
p :foo => foo, :bar => bar #=> {:foo=>"FOO", :bar=>"BAR"}
end
@raggi
Copy link

raggi commented Oct 30, 2010

#captures # ftw

I really just wish [] accepted more than one group index.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment