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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T02:44:37+00:00 2026-06-13T02:44:37+00:00

I am matching a repeating group that contains a mixture of optional and non-optional

  • 0

I am matching a repeating group that contains a mixture of optional and non-optional groups. When I iterate over the captures, the capture collections are always collapsed, i.e. they do not insert a null element for the non matched items.

Is there a way to preserve the order of matches in capture collections, such that any omitted optional item is inserted as null, thereby ensuring capture collection elements correspond across groups?

To clarify, let’s say my repeating (parent) group is matched three times, and in one of the three matches an optional child group was omitted but was present in the other two groups, I end up with a capture collection for the child group which is one element less than the other capture collections. How do I know which of the parent groups omitted the optional item?

I suppose it would be possible to use the Index property of the capture collection item and check whether it falls within the bounds of the parent group, but it would be easier if non-matches returned a null item in the capture collection. Is there a way to achieve this?

  • 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-13T02:44:38+00:00Added an answer on June 13, 2026 at 2:44 am

    Instead of (pattern)? use (pattern|) and you should get what you want…

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

Sidebar

Related Questions

Let's say I want to find all sets of 5 single-digit, non-repeating numbers that
I'm performing regex matching in .NET against strings that look like this: 1;#Lists/General Discussion/Waffles
I've got a regex that's matching a given pattern(obviously, thats what regex's do) and
I have strings like below: @property.one@some text here@property.two@another optional text here etc which contains
I find the class Regex in .net extremely useful (for both matching and matching/replacing).
The stereo matching problem consists of obtaining a correspondence between right and left images.
I'm matching the following strings: watermark=testing watermark=text-testing|position-24-50 watermark=text-testing|position-24-50|color-6aa6cc watermark=text-testing|position-24-50|color-6aa6cc|size-48 using the following regex: watermark=(text-\w+\|position-\d+-\d+\|color-([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})\|size-\d+|text-\w+\|position-\d+-\d+\|color-([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})|text-\w+\|position-\d+-\d+|\w+)
This simple regex matching returns a string instead of an object on every browser
Possible Duplicate: Regex for matching javadoc fragments I have files having content like /**
Eclipse does not highlight matching variables for me: I've already tried to change Mark

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.