/*
* call-seq:
* rxp =~ str => integer or nil
*
* Match---Matches <i>rxp</i> against <i>str</i>.
*
* /at/ =~ "input data" #=> 7
* /ax/ =~ "input data" #=> nil
*
* If <code>=~</code> is used with a regexp literal with named captures,
* captured strings (or nil) is assigned to local variables named by
* the capture names.
*
* /(?<lhs>\w+)\s*=\s*(?<rhs>\w+)/ =~ " x = y "
* p lhs #=> "x"
* p rhs #=> "y"
*
* If it is not matched, nil is assigned for the variables.
*
* /(?<lhs>\w+)\s*=\s*(?<rhs>\w+)/ =~ " x = "
* p lhs #=> nil
* p rhs #=> nil
*
* This assignment is implemented in the Ruby parser.
* So a regexp literal is required for the assignment.
* The assignment is not occur if the regexp is not a literal.
*
* re = /(?<lhs>\w+)\s*=\s*(?<rhs>\w+)/
* re =~ " x = "
* p lhs # undefined local variable
* p rhs # undefined local variable
*
* A regexp interpolation, <code>#{}</code>, also disables
* the assignment.
*
* rhs_pat = /(?<rhs>\w+)/
* /(?<lhs>\w+)\s*=\s*#{rhs_pat}/ =~ "x = y"
* p lhs # undefined local variable
*
*/
VALUE
rb_reg_match(VALUE re, VALUE str)
{
long pos = reg_match_pos(re, &str, 0);
if (pos < 0) return Qnil;
pos = rb_str_sublen(str, pos);
return LONG2FIX(pos);
}