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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T00:11:32+00:00 2026-06-01T00:11:32+00:00

I am developing a windows application in C#. I have been searching for the

  • 0

I am developing a windows application in C#. I have been searching for the solution to my problem in creating a Regex pattern. I want to create a Regex pattern matching the either of the following strings:

XD=(111111) XT=(   588.466)m3 YT=(      .246)m3 G=( 3.6)V N=(X0000000000) M=(Y0000000000) O=(Z0000000000) Date=(06.01.01)Time=(00:54:55) Q=(       .00)m3/hr

XD=(111   ) XT=(   588.466)m3 YT=(      .009)m3 G=( 3.6)V N=(X0000000000) M=(Y0000000000) O=(Z0000000000) Date=(06.01.01)Time=(00:54:55) Q=(       .00)m3/hr

The specific requirement is that I need all the values from the above given string which is a collection of key/value pairs. Also, would like to know the right approach (in terms of efficiency and performance) out of the two…Regex pattern matching or substring, for the above problem.

Thank you all in advance and let me know, if more details are required.

  • 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-01T00:11:33+00:00Added an answer on June 1, 2026 at 12:11 am

    I don’t know C#, so there probably is a better way to build a key/value array. I constructed a regex and handed it to RegexBuddy which generated the following code snippet:

    StringCollection keyList = new StringCollection();
    StringCollection valueList = new StringCollection();
    StringCollection unitList = new StringCollection();
    try {
        Regex regexObj = new Regex(
            @"(?<key>\b\w+)      # Match an alphanumeric identifier
            \s*=\s*              # Match a = (optionally surrounded by whitespace)
            \(                   # Match a (
            \s*                  # Match optional whitespace
            (?<value>[^()]+)     # Match the value string (anything except parens)
            \)                   # Match a )
            (?<unit>[^\s=]+      # Match an optional unit (anything except = or space)
            \b                   # which must end at a word boundary
            (?!\s*=)             # and not be an identifier (i. e. followed by =)
            )?                   # and is optional, as mentioned.", 
            RegexOptions.IgnorePatternWhitespace);
    
        Match matchResult = regexObj.Match(subjectString);
        while (matchResult.Success) {
            keyList.Add(matchResult.Groups["key"].Value);
            valueList.Add(matchResult.Groups["value"].Value);
            unitList.Add(matchResult.Groups["unit"].Value);
            matchResult = matchResult.NextMatch();
        } 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been developing a C# windows form application in XP. It all works
I'm developing a twitter application for Windows Phone 7 and have been doing some
Hai every one I am developing an windows application in which i have to
I am developing windows CE 6.0 for VIA board. I have a MFC application
Hi all i am developing a chat application ... i have multiple chat windows
I am Developing Windows Form Application in .Net, I want to insert selected rows
I have been developing a new JavaScript application which is rapidly growing in size.
I have been developing a Java application using J2EE and a Derby database. My
I have been developing a web application on XP and FF (with occasional IE
I have an ASP.NET MVC application that I'm working on. I've been developing it

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.