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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T11:17:30+00:00 2026-06-14T11:17:30+00:00

In some Rails code (cucumber features’ steps definitions, javascripts, rails_admin gem) I found this

  • 0

In some Rails code (cucumber features’ steps definitions, javascripts, rails_admin gem) I found this regular expression parts:

string =~ /some regexp.+rules should match "(.*?)"/i

I do have some knowledge at regular expressions and i know that * and ? symbols are similar but whilst asterisk means zero and more, the question mark means could be present or could be not.

So, using the question mark near the group of symbols makes its presence non-required within the phrase being tested. What’s the… well… the trick of using it near the non-required already group (skipping requirement is made using the asterisk afaik)?

  • 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-14T11:17:32+00:00Added an answer on June 14, 2026 at 11:17 am

    Right after a quantifier (like *), the ? has a different meaning and makes it “ungreedy”. So while the default is that * consumes as much as possible, *? matches as little as possible.

    In your specific case, this is relevant for strings like this:

    some regexp rules should match "some string" or "another"
    

    Without the question mark the regex matches the full string (because .* can consume " just like anything else) and some string" or "another is captured. With the use of the question mark, the match will stop as soon as possible, (so after ...some string") and will capture only some string.

    Further reading.

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

Sidebar

Related Questions

I am trying to use some rails code withing a javascript and need to
[Rails] I need to run some code only 40% of the times, how may
I have some code to display a long list of languages inside Rails form
I am writing some Ruby code, not Rails, and I need to handle something
I'm trying to get some RJS code written with prototype and Rails 2.3.11 to
I'm writing some Rails code for a partial view, and I want it to
I have started some rails tutorials and noticed that some of the view code
I'm using Herkou for some Rails 3 hosting. I have pushed code to Heroku,
The problem with cucumber on Rails 3. This is looks similar to Ruby on
I'm studying some Rails 3 code from Spree: module Spree module Generators class SiteGenerator

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.