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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T12:15:20+00:00 2026-06-15T12:15:20+00:00

I have the following example of a string with regex which I am trying

  • 0

I have the following example of a string with regex which I am trying to match:

Regex:
^\d{3}( [0-9a-fA-F]{2}){3}

String to match:
010 00 00 00

My question is this – the regex matches and captures 1 group – the final 00 at the end of the string. However, I want it to match all three of the 00 groups at the end. Why doesn’t this work? Surely the brackets should mean that they are all matched equally?

I know that I could just type out the three groups separately but this is just a short extract of a much longer string so that would be a pain. I was hoping that this would provide a more elegant solution but it seems my understanding is lacking somewhat!

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-15T12:15:24+00:00Added an answer on June 15, 2026 at 12:15 pm

    Because you have a quantifier on a capture group, you’re only seeing the capture from the last iteration. Luckily for you though, .NET (unlike other implementations) provides a mechanism for retrieving captures from all iterations, via the CaptureCollection class. From the linked documentation:

    If a quantifier is applied to a capturing group, the CaptureCollection includes one Capture object for each captured substring, and the Group object provides information only about the last captured substring.

    And the example provided from the linked documentation:

      // Match a sentence with a pattern that has a quantifier that  
      // applies to the entire group.
      pattern = @"(\b\w+\W{1,2})+";
      match = Regex.Match(input, pattern);
      Console.WriteLine("Pattern: " + pattern);
      Console.WriteLine("Match: " + match.Value);
      Console.WriteLine("  Match.Captures: {0}", match.Captures.Count);
      for (int ctr = 0; ctr < match.Captures.Count; ctr++)
         Console.WriteLine("    {0}: '{1}'", ctr, match.Captures[ctr].Value);
    
      Console.WriteLine("  Match.Groups: {0}", match.Groups.Count);
      for (int groupCtr = 0; groupCtr < match.Groups.Count; groupCtr++)
      {
         Console.WriteLine("    Group {0}: '{1}'", groupCtr, match.Groups[groupCtr].Value);
         Console.WriteLine("    Group({0}).Captures: {1}", 
                           groupCtr, match.Groups[groupCtr].Captures.Count);
         for (int captureCtr = 0; captureCtr < match.Groups[groupCtr].Captures.Count; captureCtr++)
            Console.WriteLine("      Capture {0}: '{1}'", captureCtr, match.Groups[groupCtr].Captures[captureCtr].Value);
      }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to match the following string in Javascript Regex PC123456 This is
Say I have the following pattern: INDICATOR\s+([a-z0-9]+) which would match for example: INDICATOR AA
I'm trying to usa a regex which only matches string which doesn't start with
Take the following example, I have a class public class SomeItem { public string
Following is the example I have reproduced: charName :: Char -> String charName 'a'
I'm trying to figure out how XSLT process namespace prefixes and have following example:
I have the following example in a SQL table Cust Group Sales A 1
i am working on a regex match function in python. i have the following
I'm trying to match a CUSIP number. I have the following, but it is
I have the following pattern definition: private static final String D = (Mon|Tue|Wed|Thu|Fri|Sat|Sun); private

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.