Niklas Frykholm wrote:

> To fully duplicate the functionality of the built-in String#index I need 
> to transfer $~ from the local scope to the enclosing scope. Is there any 
> way of doing this?

There's a solution in the ruby-talk:79283 thread that was posted by 
matz, but it's not thread safe. It would be wonderful if we could have a 
proper way of doing this...