Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4541312
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T15:12:58+00:00 2026-05-21T15:12:58+00:00

In ruby, I read some of the operators, but I couldn’t find =~ .

  • 0

In ruby, I read some of the operators, but I couldn’t find =~. What is =~ for, or what does it mean? The program that I saw has

regexs = (/\d+/)
a = somestring
if a =~ regexs

I think it was comparing if somestring equal to digits but, is there any other usage, and what is the proper definition of the =~ operator?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T15:12:59+00:00Added an answer on May 21, 2026 at 3:12 pm

    The =~ operator matches the regular expression against a string, and it returns either the offset of the match from the string if it is found, otherwise nil.

    /mi/ =~ "hi mike" # => 3 
    "hi mike" =~ /mi/ # => 3 
    
    "mike" =~ /ruby/ # => nil 
    

    You can place the string/regex on either side of the operator as you can see above.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I read from some books that Phusion Passenger is the answer to easy Ruby
I've been looking to read some ruby code(specifically Rails) but I don't want to
I read in some Microsoft documentation that PHP, together with Ruby on Rails, is
Having discussed some failure handling in Does Ruby's 'open_uri' reliably close sockets after read
I'm new to the Ruby and Ruby on Rails world. I've read some guides,
I have a simple tab-separated text file that I want Ruby to read every
Some time ago I read the changelog of a Ruby on Rails version (I
I'm using ruby to read a file and I need to somehow parse some
I have read this question , but I couldn't create a full example: class
I want to read some ruby code. And I think this is the good

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.