Skip to content
instance method

Regexp#===

(untyped other) -> bool
regexp === string → true or false

Returns true if self finds a match in string:

Example
/^[a-z]*$/ === 'HELLO' # => false
/^[A-Z]*$/ === 'HELLO' # => true

This method is called in case statements:

Example
s = 'HELLO'
case s
when /\A[a-z]*\z/; print "Lower case\n"
when /\A[A-Z]*\z/; print "Upper case\n"
else               print "Mixed case\n"
end # => "Upper case"
See also #== #=~ .union #~ also in 4.1 · 3.4 · 3.3 · 3.2 · 3.1 · 3.0