Method: String#match?
- Defined in:
- string.c
#match?(pattern, offset = 0) ⇒ Boolean
Returns true or false based on whether a match is found for self and pattern.
Note: does not update Regexp@Global+Variables.
Computes regexp by converting pattern (if not already a Regexp).
regexp = Regexp.new(pattern)
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
5019 5020 5021 5022 5023 5024 5025 5026 |
# File 'string.c', line 5019 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); } |