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 9136003
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T08:53:46+00:00 2026-06-17T08:53:46+00:00

I am using Ruby 1.9.3. Just going thorugh the Ruby tutorials. Now I just

  • 0

I am using Ruby 1.9.3. Just going thorugh the Ruby tutorials. Now I just got stuck to a statement on which regular expression is working and giving out put also. But confusion with the \/ operators logic.

RegExp-1

Today's date is: 1/15/2013. (String)

(?<month>\d{1,2})\/(?<day>\d{1,2})\/(?<year>\d{4}) (Expression)

RegExp-2

s = 'a' * 25 + 'd' 'a' * 4 + 'c' (String)

/(b|a+)*\/ =~ s #=> ( expression)

Now couldn’t understand how \/ and =~ operator works in Ruby.

Could anyome out of here help me to understand the same?

Thanks

  • 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-17T08:53:46+00:00Added an answer on June 17, 2026 at 8:53 am

    \ serves as an escape character. In this context, it is used to indicate that the next character is a normal one and should not serve some special function. normally the / would end the regex, as regex’s are bookended by the /. but preceding the / with a \ basically says “i’m not telling you to end the regex when I use this /, i want that as part of the regex.”

    As Lee pointed out, your second regex is invalid, specifically because you never end the regex with a proper /. you escape the last / so that it’s just a plaintext character, so the regex is hanging. it’s like doing str = "hello.

    as another example, normally ^ is used in regex to indicate the beginning of a string, but doing \^ means you just want to use the ^ character in the regex.

    =~ says “does the regex match the string?” If there is a match, it returns the index of the start of the match, otherwise returns nil. See this question for details.

    EDIT: Note that the ?<month>, ?<day>, ?<year> stuff is grouping. seems like you could use a bit of brush-up on regex, check out this appendix of sorts to see what all the different special characters do.

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

Sidebar

Related Questions

I've just started using Ruby on Rails and so far it's working nicely. I'm
I am using Ubuntu 9.04 I just installed ruby and rails in my system
i am using google api for ruby, but not know how to start, just
Using Ruby, I'm trying to parse some documentation in which I need to split
I am going through the Ruby tutorials from Learn to Program , and I
I maintain a ruby based application using the ruby-aws gem which interfaces with Mechanical
I've previously written some selenium tests using ruby/rspec, and found it quite powerful. Now,
I have a project which is going to use Ruby on the front end,
I just installed ruby on rails on my new computer ( I was using
I'm just starting out using Ruby and I've written a bit of code to

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.