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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T21:16:41+00:00 2026-05-23T21:16:41+00:00

Here is the requirement. I have a string with multiple entries of a particular

  • 0

Here is the requirement.

I have a string with multiple entries of a particular format. Example below

string SourceString = "<parameter1(value1)><parameter2(value2)><parameter3(value3)>";

I want to get the ouput as below

string[] parameters = {"parameter1","parameter2","parameter3"};   
string[] values = {"value1","value2","value3"};

The above string is just an example with 3 pairs of parameter values. The string may have 40, 52, 75 – any number of entries (less than 100 in one string).
Like this I have multiple strings in an array. I want to do this operation for all the strings in the array.

Could any one please advice how to achieve this? I’m a novice in c#.
Is using regex a better solution or is there any other method?
Any help is much appreciated.

  • 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-23T21:16:44+00:00Added an answer on May 23, 2026 at 9:16 pm

    If you didn’t like RegEx’s you could do something like this:

      class Program
      {
    
        static void Main()
        {
    
            string input = "<parameter1(value1)>< parameter2(value2)>";
            string[] Items = input.Replace("<", "").Split('>');
    
            List<string> parameters = new List<string>();
            List<string> values = new List<string>();
    
            foreach (var item in Items)
            {
                if (item != "")
                {
                    KeyValuePair<string, string> kvp = GetInnerItem(item);
                    parameters.Add(kvp.Key);
                    values.Add(kvp.Value);
                }
            }
    
            // if you really wanted your results in arrays
            //
            string[] parametersArray = parameters.ToArray();
            string[] valuesArray = values.ToArray();
    
        }
    
    
        public static KeyValuePair<string, string> GetInnerItem(string item)
        {
            //expects parameter1(value1)
            string[] s = item.Replace(")", "").Split('(');
            return new KeyValuePair<string, string>(s[0].Trim(), s[1].Trim());
        }
    }
    

    It might be a wee bit quicker than the RegEx method but certainly not as flexible.

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

Sidebar

Related Questions

I want to get the format of a given date string. Example: I have
Here is simplified version of my requirement I have a java class say Processor
Here's my requirement: 1. I want my installable to have a custom license agreement
I have a requirement to send mails through java. Here I am getting error
I have a requirement to disallow backslash characters in a given string field defined
I have a requirement to return two different pieces of string data through RPC
EDIT Here is the problem I am trying to solve: I have a string
Here I have 2 requirements: Need a batch file to start a process on
I am creating a installer using WIX, The requirement here is that when the
I want to model messages between users, here is the requirement: User has received

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.