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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T06:54:24+00:00 2026-05-24T06:54:24+00:00

Consider the following string: ABC . I would like to capture the following groups

  • 0

Consider the following string: ABC. I would like to capture the following groups using a regular expression:

Group1: AC
Group2: B

Both the groups have to be captured using a single regular expression. I do not have control over the code, so sub-matches or capture groups will not help.

I’ve tried both non-capturing groups and look arounds.

With a Non-Capturing group, the match is still a part of the final result.

(?<Group1>a(?:(?<Group2>b))c)

Group1: ABC # Not right as B is part of the match. Group2: B

With a lookaround, Group2 is not consumed and the regex following the look ahead should match the contents of Group2 again which includes it as part of Group1.

(?<Group1>a(?=(?<Group2>b))bc)

Group1: ABC # Not right as B is part of the match.
Group2: B

How can I ignore “B” as part of the Group1 match?

Any help on getting around this is greatly appreciated.

Thanks,
Balaji

  • 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-05-24T06:54:25+00:00Added an answer on May 24, 2026 at 6:54 am

    You can’t. Regex engines can’t paste together nonlinear submatches into a single match. Any match must be a succession of characters from the original text.

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

Sidebar

Related Questions

Consider the following string '35=_-235-b-35=35-35=2-135=a-35=123-235=2-35=a-53=1-53=a-553=b' I'd like to extract everything that matches 35= followed
Consider the following string which is a C fragment in a file: strcat(errbuf,errbuftemp); I
consider the following code: string x=3F; //0011 1111 string y=3F; //0011 1111 string result=FFF;
In C, consider the following inline string arrays: char *string1 = I'm a literal!;
I know, this is very simple for you guys. Please consider the following code:
Consider following script (it's total nonsense in pseudo-language): if (Request.hostMatch(asfasfasf.com) && someString.existsIn(new String[] {brr,
I'm working with eclipse IDE (Version: 3.4.2) on a mac and I have met
After a long day of searching, I still can't figure out how I can
I don't really understand how command line arguments work with escripts. From the manpage,
In .NET reference type arrays are co-variant. This is considered a mistake. However, I

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.