Anthony Durity asked:
> Imagine I have a bunch of n RegExps r[] - they could be any valid ruby 
> Regexps.
> Say I want to match each of them in turn to a certain something s to
> make sure that no two Regexps in the list both match s.
> Now say that I want a meta regular expression m that is all the
> Regexps merged together so that the following pseudo code wroks,
>
> m = MetaRegExp.new
> for each r { [i] m.add(r[i]) } # add makes sure that no two RegExps
> would match the same input
>
> m =~ s # returns an int representing which of the n original RegExps
> would have matched

Why not just use the array of regexps like this?

matches = r.map{|i| r =~ s }
matches.index(matches.select{|i| i }[0])  # returns the int you're after

Cheers,
Dave