It matches string to a regular expression.
'hello' =~ /^h/ # => 0
If there is no match, it will return nil
. If you pass it invalid arguments (ie, left or right-hand sides are not correct), it will either throw a TypeError
or return false
.
More Related Contents:
- What does map(&:name) mean in Ruby?
- What does ||= (or-equals) mean in Ruby?
- Difference between “or” and || in Ruby? [duplicate]
- Difference between “and” and && in Ruby?
- What is Ruby’s double-colon `::`?
- What is the Ruby (spaceship) operator?
- What does the (unary) * operator do in this Ruby code?
- Why doesn’t Ruby support i++ or i– (increment/decrement operators)?
- What’s the difference between equal?, eql?, ===, and ==?
- No increment operator (++) in Ruby? [duplicate]
- Is there any wisdom behind “and”, “or” operators in Ruby?
- list of ruby operators that can be overridden/implemented
- Understanding the “||” OR operator in If conditionals in Ruby
- What does the unary question mark (?) operator do?
- Parsing a JSON string in Ruby
- How to set TLS context options in Ruby (like OpenSSL::SSL::SSL_OP_NO_SSLv2)
- Why does installing Nokogiri on Mac OS fail with libiconv is missing?
- Pass variables to Ruby script via command line
- What is the difference between Ruby 1.8 and Ruby 1.9
- Is there a reason that we cannot iterate on “reverse Range” in ruby?
- How can I capture STDOUT to a string?
- What do you call the -> operator in Ruby?
- Understanding Ruby’s load paths
- git, Heroku: pre-receive hook declined
- Understanding private methods in Ruby
- Iterate through every file in one directory
- Overriding method by another defined in module
- Ruby gem for finding timezone of location [closed]
- Is it possible to have class.property = x return something other than x?
- Ruby local variable is undefined