Method: U::String#match

Defined in:
ext/u/rb_u_string_match.c

#match(pattern, index = 0) ⇒ MatchData? #match(pattern, index = 0) {|matchdata| ... } ⇒ Object?

Overloads:

  • #match(pattern, index = 0) ⇒ MatchData?

    Returns The result of r#match(self, index), that is, the match data of the first match of r in the receiver, inheriting any taint and untrust from both the receiver and from PATTERN, if one exists, where r = PATTERN, if PATTERN is a Regexp, r = Regexp.new(PATTERN) otherwise.

    Parameters:

    • pattern (Regexp, #to_str)
    • index (#to_int) (defaults to: 0)

    Returns:

    • (MatchData, nil)

      The result of r#match(self, index), that is, the match data of the first match of r in the receiver, inheriting any taint and untrust from both the receiver and from PATTERN, if one exists, where r = PATTERN, if PATTERN is a Regexp, r = Regexp.new(PATTERN) otherwise

  • #match(pattern, index = 0) {|matchdata| ... } ⇒ Object?

    Returns The result of calling the given block with the result of r#match(self, index), that is, the match data of the first match of r in the receiver, inheriting any taint and untrust from both the recevier and from PATTERN, if one exists, where r = PATTERN, if PATTERN is a Regexp, r = Regexp.new(PATTERN) otherwise.

    Parameters:

    • pattern (Regexp, #to_str)
    • index (#to_int) (defaults to: 0)

    Yield Parameters:

    • matchdata (MatchData)

    Returns:

    • (Object, nil)

      The result of calling the given block with the result of r#match(self, index), that is, the match data of the first match of r in the receiver, inheriting any taint and untrust from both the recevier and from PATTERN, if one exists, where r = PATTERN, if PATTERN is a Regexp, r = Regexp.new(PATTERN) otherwise



52
53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'ext/u/rb_u_string_match.c', line 52

VALUE
rb_u_string_match_m(int argc, VALUE *argv, VALUE self)
{
        VALUE re;
        if (argc < 0)
                need_m_to_n_arguments(argc, 1, 2);
        re = argv[0];
        argv[0] = self;
        VALUE result = rb_funcall2(rb_u_pattern_argument(re, false),
                                   rb_intern("match"), argc, argv);
        if (!NIL_P(result) && rb_block_given_p())
                return rb_yield(result);
        return result;
}