Avoid using $~ as an out parameter in Regexp search/match logic.

This fixes issues where threads would step on each others results
by updating $~ between the time the match was created deeper in
the stack and retrieved higher up. The result was that the match
logic would return another thread's MatchData.

My fix is to never read $~ in these methods and only ever write
it; this does not help the issue (across all impls) where $~ is
shared and not reliable across threads, but it should fix issues
where it was being used internally to pass MatchData to calls
higher in the stack.

Fixes JRUBY-7167 and JRUBY-7176.