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

  • Home
  • SEARCH
  • 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 135547
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T06:48:28+00:00 2026-05-11T06:48:28+00:00

I have a C# Regex class matching multiple subgroups such as (?<g1>abc)|(?<g2>def)|(?<g3>ghi) but with

  • 0

I have a C# Regex class matching multiple subgroups such as

(?<g1>abc)|(?<g2>def)|(?<g3>ghi)  

but with much more complicated sub-patterns. I basically want to match anything that doesn’t belong to any of those groups, in addition to existing groups.

I tried

(?<g1>abc)|(?<g2>def)|(?<g3>ghi)|(.+?)  

but it turned out too slow. I can’t do negation because I don’t want to copy those complex subpatterns redundantly. Using just (.+) overrides all other groups as expected.

Is there any other way? If that doesn’t work I’ll have to write an ad-hoc parser.

Additional details: All these groups are evaluated against a MatchEvaluator. So a Regex class behavior that sends ‘unmatched strings’ to the MatchEvaluator will also work.

A sample text would be

.......abc........ghi.....def.....abc....def...ghi......abc....... 

I want to catch parts inbetween.

  • 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. 2026-05-11T06:48:28+00:00Added an answer on May 11, 2026 at 6:48 am

    Your regex generates separate match for every single character outside g1,g2,g3. So when you use it with MatchEvaluator it generates lots of evaluator calls. Thats why its slow.

    If you try following regex:

    (?<rest>.*?)((?<g1>abc)|(?<g2>def)|(?<g3>ghi)|$) 

    you will get single ‘rest’ group match for entire fragment of text that doesnt contain ‘g’ group.

    Regex C# code:

    Regex regex = new Regex(     @'(?<rest>.*?)((?<g1>abc)|(?<g2>def)|(?<g3>ghi)|$)',     RegexOptions.Singleline     | RegexOptions.Compiled     ); 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have written a class using std::tr1::regex, and I don't know how to link
I have a RegEx that is working for me but I don't know WHY
Anyone have a regex to strip lat/long from a string? such as: ID: 39.825
I have this regex working but now need to allow numbers without the decimal
I have the next re using the c# regex class: [^\r\n]+[^,condicionesDePago] searching in the
I know, I know, now I have two problems 'n all that, but regex
I have the following classes: Public Class Email Private Shared ReadOnly EMAIL_REGEX = \b[a-zA-Z]+[a-zA-Z0-9._+-]+@
I have a regex that is going to end up being a bit long
I have a regex call that I need help with. I haven't posted my
I have this regex I built and tested in regex buddy. _ [ 0-9]{10}+

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.