match(p1)
public
Returns a MatchData object
describing the match, or nil if there was no match. This is equivalent to retrieving the
value of the special variable $~ following a normal match.
/(.)(.)(.)/.match("abc")[2]
Show source
/*
* call-seq:
* rxp.match(str) => matchdata or nil
*
* Returns a <code>MatchData</code> object describing the match, or
* <code>nil</code> if there was no match. This is equivalent to retrieving the
* value of the special variable <code>$~</code> following a normal match.
*
* /(.)(.)(.)/.match("abc")[2]
*/
static VALUE
rb_reg_match_m(re, str)
VALUE re, str;
{
VALUE result = rb_reg_match(re, str);
if (NIL_P(result)) return Qnil;
result = rb_backref_get();
rb_match_busy(result);
return result;
}