Project

General

Profile

Feature #11100 ยป string_slice_many_captures.patch

0x0dea (D.E. Akers), 04/27/2015 07:04 AM

View differences:

string.c
3581 3581
static VALUE
3582 3582
rb_str_subpat(VALUE str, VALUE re, VALUE backref)
3583 3583
{
3584
    int i, nth;
3585

  
3584 3586
    if (rb_reg_search(re, str, 0, 0) >= 0) {
3585 3587
        VALUE match = rb_backref_get();
3586
        int nth = rb_reg_backref_number(match, backref);
3587
	return rb_reg_nth_match(nth, match);
3588
        if (RB_TYPE_P(backref, T_ARRAY)) {
3589
            VALUE result = rb_ary_new();
3590
            for (i = 0; i < RARRAY_LEN(backref); i++) {
3591
                nth = rb_reg_backref_number(match, rb_ary_entry(backref, i));
3592
                rb_ary_push(result, rb_reg_nth_match(nth, match));
3593
            }
3594
            return result;
3595
        }
3596
        nth = rb_reg_backref_number(match, backref);
3597
        return rb_reg_nth_match(nth, match);
3588 3598
    }
3589 3599
    return Qnil;
3590 3600
}