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

  • SEARCH
  • Home
  • 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 8477777
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T18:33:32+00:00 2026-06-10T18:33:32+00:00

I have found a code for checking whether string is numeric. And it works

  • 0

I have found a code for checking whether string is numeric. And it works fine. But I am not
getting how is it working. Can anyone explain it.

    str = "12132344", str1="abcd", str2="12213234.132332"

    /^[\d]+(\.[\d]+){0,1}$/ === str  #=> true  //perfect
    /^[\d]+(\.[\d]+){0,1}$/ === str1 #=> false //perfect
    /^[\d]+(\.[\d]+){0,1}$/ === str2 #=. true  //perfect

when i change the comparison like below:

    str === /^[\d]+(\.[\d]+){0,1}$/ #=>  false
    str1 === /^[\d]+(\.[\d]+){0,1}$/ #=> false
    str2 === /^[\d]+(\.[\d]+){0,1}$/ #=> false

Also I found alternate way to do this by using match.

Can anyone explain what is (===) operator doing here? How it works? Is there any other alternate way?

  • 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-06-10T18:33:34+00:00Added an answer on June 10, 2026 at 6:33 pm

    In Ruby, operator overloading can be used to define what each operator does, but it must be done by the class on the left hand side of the operator.

    This method is defined in the Ruby Standard Library for the Regexp object class. Reference: http://www.ruby-doc.org/core-1.9.3/Regexp.html#method-i-3D-3D-3D.

    It only works with the Regexp class (that is the pattern) on the left hand side because it is defined to work that way only in the Regexp class.

    In this case, Regexp defines === as a synonym for =~, which matches a string given a regular expression pattern.

    The String class defines the === operator as an equality operator. This means it returns false if the right hand argument is not a string, and otherwise returns true only if both strings match. Reference: http://www.ruby-doc.org/core-1.9.3/String.html#method-i-3D-3D-3D

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

Sidebar

Related Questions

I have found some code snippet in the internet. But it is missing some
What I have found so far in many cases python code for checking business
I have found this bit of web.config code for checking the url to see
I have a simple code checking if image url is valid. Unfortunately whether image
I have found some code which recognize circles in particular image and I was
I have found the code which links against of 'g2c' library. Why do I
I have found some code on measuring execution time here http://www.dreamincode.net/forums/index.php?showtopic=24685 However, it does
I have found this code for reverse geocoding: var point = new GLatLng (lat[1],long[1]);
I want to force the download of an image. I have found this code:
I have found this line of code in a game that I study int

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.