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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T20:34:43+00:00 2026-05-11T20:34:43+00:00

I have some text data in this format: MI 00 3 MD 1 0.0000

  • 0

I have some text data in this format:

MI
00
3

MD
1
0.0000
MD
2
0.0000
MD
3
0.0000

This block can be repeated and the number of MDs is variable (but always >= 1) and the numeric values following need to be captured for each one.

I have a regex that matches every MD per MI but it will only capture the last MD. Is it possible to capture each MD without knowing in advance how many there are?

EDIT: Per requests…
Regex is below; the important part of my question remains “can I capture every MD set?”

MI\r\d\d\r(\d)\r[\s\w]{6}\r(MD\r[\s\d]{2}\r[\s\d\.\-]*\r)+

My language of choice is C# but I’d take an answer in any language because it would at least give me a start.

MD is a data point out of a sulfur detector from the early 90s.

  • 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-11T20:34:43+00:00Added an answer on May 11, 2026 at 8:34 pm

    Every Match has a Groups collection. In your case Matches[0].Groups[1] would match the MD records, like “MD\n1\n0.0000MD\n2\n0.0000MD\n3\n0.0000”.

    Every Group has a Captures collection, which you can iterate over to find all MD instances. This will give you one string per MD, so Matches[0].Groups[1].Captures[0] will be “MD\n1\n0.0000”.

    EDIT: Although you’ve already accepted the answer, here’s a way to parse everything in a single go:

    string pat = @"MI[\r\n]*(?<MI1>\d\d)[\r\n]*(?<MI2>\d+)[\r\n]*" +
        @"(MD[\r\n]*(?<MD1>\d+)*[\r\n]*(?<MD2>[\d\.\-]+)+[\r\n]*)*";
    
    var r = new Regex(pat);
    foreach (Match match in r.Matches(text))
    {
        Console.WriteLine("MI v1:{0} v2:{1}", 
             match.Groups["MI1"], match.Groups["MI2"]);
    
        if (match.Groups.Count > 2)
            for (var i = 0; i < match.Groups["MD1"].Captures.Count; i++)
                Console.WriteLine("  MD v1:{0} v2:{1}", 
                    match.Groups["MD1"].Captures[i], 
                    match.Groups["MD2"].Captures[i]);
    }
    

    This is the test text I used:

    MI
    00
    3
    
    MD
    1
    0.1000
    MD
    2
    0.2000
    MD
    3
    0.3000
    
    MI
    12
    5
    
    MI
    24
    5
    
    MD
    1
    0.1000
    

    The output is:

    MI v1:00 v2:3
      MD v1:1 v2:0.1000
      MD v1:2 v2:0.2000
      MD v1:3 v2:0.3000
    MI v1:12 v2:5
    MI v1:24 v2:5
      MD v1:1 v2:0.1000
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Alright, so I have a text file with some data in it, in this
I have some data in JSON format in a text file as below. I
I have a text file having some data in following format %app_lookup_strings = (
We have some C# code that reads data from a text file using a
I have some text on a page that is small but readable in Chrome/Safari
I have some text stored in a variable which contains some HTML. For example,
I have some text. Is there is any api which can tell me the
I have some text that I always need to display (like a HUD). When
I have a code similar to this: $.ajax({ success: function(data) { text = '';
Assume that I have some array of data (a vector to be specific). Can

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.