/* * call-seq: * mtch.pre_match => str * * Returns the portion of the original string before the current match. * Equivalent to the special variable <code>$`</code>. * * m = /(.)(.)(\d+)(\d)/.match("THX1138.") * m.pre_match #=> "T" */ VALUE rb_reg_match_pre(match) VALUE match; { VALUE str; if (NIL_P(match)) return Qnil; if (RMATCH(match)->BEG(0) == -1) return Qnil; str = rb_str_substr(RMATCH(match)->str, 0, RMATCH(match)->BEG(0)); if (OBJ_TAINTED(match)) OBJ_TAINT(str); return str; }