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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T20:16:04+00:00 2026-06-14T20:16:04+00:00

key1=value1 http://www.example.com?a=1;key2=value2 http://www.example.com?a=2; I need to split the above line 2 times, the first

  • 0
"key1"="value1 http://www.example.com?a=1";"key2"="value2 http://www.example.com?a=2";

I need to split the above line 2 times, the first time it is the comma character ; and the second time on the = sign.

It doesn’t work correctly because the value part has the = sign in it also.

My code doesn’t work as it was assuming the value part doesnt’ have an = sign in it, and it isn’t using regex simply String.Split(‘=’).

Can someone help with the regex required, I added double quotes around both the key/value to help keep things seperate.

  • 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-14T20:16:05+00:00Added an answer on June 14, 2026 at 8:16 pm

    Use the String.Split(char[], int) overload (http://msdn.microsoft.com/en-us/library/c1bs0eda.aspx). The second parameter will limit the number of substrings to return. If you know your strings will always have at least 1 equal sign (key/value pairs), then set the second parameter to 2.

    string x = "key1=value1 http://www.example.com?a=1;key2=value2 http://www.example.com?a=2;";
    char[] equal = new char[1] { '=' };
    char[] semi = new char[1] { ';' };
    string[] list = x.Split(semi, StringSplitOptions.RemoveEmptyEntries);
    foreach (string s in list)
    {
        string[] kvp = s.Split(equal, 2);
        Console.WriteLine("Key: {0}, Value: {1}", kvp[0], kvp[1]);
    }
    

    –
    Result:

    Key: key1, Value: value1 http://www.example.com?a=1
    Key: key2, Value: value2 http://www.example.com?a=2
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

http://www.myserver.com/exile?Key1=Value1&Key2=Value2 When i get a request in this format to my server, how do
http://www.google.se/search?Key1=Value1&Key2=Value2 Can i get some technical idea about this link?? I am aware of
I need to parse a JSON Response that looks like: {key1: value1, key2: value2,
I have a String: "{key1:value1}{key2:value2}" . I want to split these string using regular
I have {key1:value1, key2:value2, etc} I want it to become: [key1,value1,key2,value2] , if certain
Say I have a file with the format: key1/value1 key2/value2 key3/value3 .... Say I
suppose I have a object: obj:{ child:{ x:12, y:50 }, key1:value1, key2:value2 } if
String input = key1=value1&key2=value2&key3=value3&key4=value4&key5=value5; How can I store the key-value pairs into a HashMap
Given the object: var firstObject = { key1 : 'value1', key2 : 'value2' };
I have the object var dataformdata={key1:value1,key2:value2}; then I add some more values with the

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.