diff options
Diffstat (limited to 're.c')
-rw-r--r-- | re.c | 15 |
1 files changed, 14 insertions, 1 deletions
@@ -727,6 +727,19 @@ last_match_getter() } static VALUE +rb_reg_s_last_match(argc, argv) + int argc; + VALUE *argv; +{ + VALUE nth; + + if (rb_scan_args(argc, argv, "01", &nth) == 1) { + rb_reg_nth_match(NUM2INT(nth), rb_backref_get()); + } + return rb_reg_last_match(rb_backref_get()); +} + +static VALUE prematch_getter() { return rb_reg_match_pre(rb_backref_get()); @@ -1347,7 +1360,7 @@ Init_Regexp() rb_define_singleton_method(rb_cRegexp, "compile", rb_reg_s_new, -1); rb_define_singleton_method(rb_cRegexp, "quote", rb_reg_s_quote, -1); rb_define_singleton_method(rb_cRegexp, "escape", rb_reg_s_quote, -1); - rb_define_singleton_method(rb_cRegexp, "last_match", match_getter, 0); + rb_define_singleton_method(rb_cRegexp, "last_match", rb_reg_s_last_match, 0); rb_define_method(rb_cRegexp, "initialize", rb_reg_initialize_m, -1); rb_define_method(rb_cRegexp, "clone", rb_reg_clone, 0); |