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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T13:05:25+00:00 2026-06-17T13:05:25+00:00

Is it possible to have a .net regex pattern that references the numeric value

  • 0

Is it possible to have a .net regex pattern that references the numeric value of a previously captured group in another part of the pattern? I need to match strings that repeat the following format:

  • 10-byte alpha key followed by 2-byte operator (subset of sql operators) followed by 5 integer digits followed by an n-byte value, where n = the integer value of the 5 integer digits.

EX String:
“key1 = 00004val1key2 <=00006value2key3 >=00011value_three”

Where val1 is 4-bytes, value2 is 6-bytes, value_three is 11-bytes, etc…. This string represents repeating set of criteria that I need to be able to parse and identify the following strings:

1st Criteria:
“key1”, “= “, “val1”

2nd Criteria:
“key2”, “<=”, “value2”

3rd Criteria:
“key3”, “>=”, “value_three”

I’ve used .net regex’s in the past and should be able to figure out parsing the key, operator and digits in a repeating pattern, but don’t know how, or even if, it is possible to reference the numeric value of the digits (i.e. an integer with value of 4 for the string “00004”) later in the pattern.

Update 1
Originally I was thinking that I needed a regex pattern such as:

^(?<criteria>(?<key>\w{10})(?<operator>(= |<=|>=))(?<value_length>\d{5})(?<value>\w{n}))+$

where the {n} quantifier in the “value” capturing group needs to have a value based on the value of the “value_length” capturing group, for each “criteria” captured. If this is not the right way to think about forming the regex pattern, I can change to another approach that works.

  • 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-17T13:05:26+00:00Added an answer on June 17, 2026 at 1:05 pm

    You can instead capture the required length string in the match itself till the next \w{10} and operator (= |<=|>=) using lookahead

    string regex=@"(?<key>\w{10})(?<operator>(= |<=|>=))(?<value_length>\d{5})(?<value>.*?(?=\w{10}(= |<=|>=)|$))";
    foreach(Match m in Regex.Matches(input,regex,RegexOptions.Singleline))
    {
        int vLen=int.Parse(m.Groups["value_length"].Value);
        string requiredString=m.Groups["value"].Value.Substring(0,vLen-1);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using Regex in .Net I will have a set of data that comes in
It is possible to have WCF Client that connects persistantly using duplex over net.tcp
Is it possible to have an ASP.NET MVC route that uses subdomain information to
Is it possible to have a multi-line textbox (im using asp.net c#) where the
Is it possible to have multiple login pages for different folders within an asp.net
First, is it possible to have n transactions levels over ADO.Net. Second, is this
Possible Duplicate: How to: Back button support “Ajax” I have a ASP.NET MVC implementation
Possible Duplicate: ASP.Net:Best way to run scheduled tasks I have to make a scheduled
Possible Duplicate: Modifying .NET Dictionary while Enumerating through it I have a dictionary object
Possible Duplicate: Read Post Data submitted to ASP.Net Form I have a google checkout

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.