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

The Archive Base Latest Questions

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

I was reading the topic grouping in Regex from the doc Grouping .I found

  • 0

I was reading the topic grouping in Regex from the doc Grouping.I found there one example and started to play with it to understand the behaviors/roles of ?<option>: in Regex. The code is used to undersatnd it as below:

%w{CASE case CAse caSE cASe casE}­.grep /(?i:­ca)se/
# => ["case", "CAse"] 
%w{CASE case CAse caSE cASe casE}­.grep /(?:c­a)se/
# => ["case"]
%w{CASE case CAse caSE cASe casE}­.grep /(:ca­)se/
# => []
%w{CASE case CAse caSE cASe casE}­.grep /(i:c­a)se/
# => []

Now I am totally confused about the operations performed by (?i:­ca,(?:c­a)se,(:ca­),(i:c­a). Each syntax is valid as per the output,otherwise I might get error from the console.

Could any one please help me to understand how the outputs have been generated by the code above, and what the special roles are of ?<option>: in grouping of Regex?

  • 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-17T11:35:44+00:00Added an answer on June 17, 2026 at 11:35 am
    > %w{CASE case CAse caSE cASe casE}­.grep /(?i:­ca)se/
    => ["case", "CAse"] 
    

    Non-capturing group (?<option>:pattern), with case-insensitive flag on i. The pattern is ca. The case-insensitive flag is only effective within the non-capturing group, so ca is matched case-insensitive, while se is matched case-sensitive. This is a useful construct to activate certain effect for only part of the regex.

    Non-capturing group will not store the position of the text matched by the pattern inside the group, as opposed to capturing group (pattern) that doesn’t start with ? after (.

    > %w{CASE case CAse caSE cASe casE}­.grep /(?:c­a)se/
    => ["case"]
    

    This is just a plain non-capturing group without any option, with ca as pattern. As the document described, the <option> in (?<option>:pattern) can be empty. There is nothing special here, just match case-sensitively.

    > %w{CASE case CAse caSE cASe casE}­.grep /(:ca­)se/
    => []
    

    This is a capturing group, with :ca as pattern (colon :, c then a). Of course, no match found.

    > %w{CASE case CAse caSE cASe casE}­.grep /(i:c­a)se/
    => []
    

    Again, a capturing group, with i:ca as pattern (i, colon :, c, then a). No match found also.

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

Sidebar

Related Questions

I'm reading the msdn library topic about genrics . There is an example of
i have one problem controlling checkbox, i'm reading, and searching about the topic but
Reading the Scala by Example book and there is this example when Martin explains
Reading online about this topic is confusing. Is there a way to cut around
I've been reading around a few different guides/tutorials on this topic and found the
http://docs.djangoproject.com/en/dev/topics/logging/#topic-logging-parts-loggers I'm reading this doc. What happens when you log something? Where does it
I am reading algorithm analysis topic. Here is the text snippet from the book
Good day! I am reading Manning's struts2 book and one of the topic is
I know there are many questions concerning this topic but after reading them all
I was reading the following topic How do JavaScript closures work? and found this

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.