Ruby Newbie homepage Ruby Newbie homepage

How to use

Quick guide

Official content
Returns true or false based on whether a match is found for self and pattern.
Note: does not update Regexp-related global variables.
Computes regexp by converting pattern (if not already a Regexp).
regexp =
Returns true if self+.match(regexp) returns a Matchdata object, false otherwise:
'foo'.match?(/o/) # => true
'foo'.match?('o') # => true
'foo'.match?(/x/) # => false
If Integer argument offset is given, the search begins at index offset:
'foo'.match?('f', 1) # => false
'foo'.match?('o', 1) # => true
               static VALUE
rb_str_match_m_p(int argc, VALUE *argv, VALUE str)
    VALUE re;
    rb_check_arity(argc, 1, 2);
    re = get_pat(argv[0]);
    return rb_reg_match_p(re, str, argc > 1 ? NUM2LONG(argv[1]) : 0);

Was this page useful?