Oh, now that’s annoying.

How about using [`Regexp.last_match`](http://www.ruby-doc.org/core-1.9.3/Regexp.html#method-c-last_match) instead of `$~`? At least that means you have explicit, well-named globals rather than cryptic ones. And `captures` is more explicit in intent than `to_a[1..-1]`.