/* * call-seq: * mtch.begin(n) => integer * * Returns the offset of the start of the <em>n</em>th element of the match * array in the string. * * m = /(.)(.)(\d+)(\d)/.match("THX1138.") * m.begin(0) #=> 1 * m.begin(2) #=> 2 */ static VALUE match_begin(match, n) VALUE match, n; { int i = NUM2INT(n); if (i < 0 || RMATCH(match)->regs->num_regs <= i) rb_raise(rb_eIndexError, "index %d out of matches", i); if (RMATCH(match)->regs->beg[i] < 0) return Qnil; return INT2FIX(RMATCH(match)->regs->beg[i]); }