On Sunday 27 March 2005 05:29 pm, Florian Gross wrote:
> puts $~.captures
>
> Avoiding the perlish variable:
>
> if md = /foo(.+)bar(.+)qux/.match(str) then
>    puts md.captures
> end
>
> or
>
> puts Regexp.last_match.captures

Thanks!  Those definitley seem more Rubyish, and once I realized the results 
were in an array, I was able to do this (to format the output):

(1..10).each {|i| puts "$" + i.to_s + " is: " + Regexp.last_match.captures[i - 
1].to_s}

Gives, e.g:

$1 is: http:
$2 is: //blah/blah
...

And I can see how to make unit tests for each RE, although I may wait until 
all my REs are done and I have a scanner, then do a "unit test" on a specific 
document with examples of each thing that should be matched and its proper 
translation (or parsing).

regards,
Randy Kramer