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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T10:01:01+00:00 2026-05-29T10:01:01+00:00

This is a pretty complex regular expression that returns an array of key/value pairs

  • 0

This is a pretty complex regular expression that returns an array of key/value pairs from a proprietary string of data. Here is sample of the data, in case the express can not be used in .Net and another method needs to be used.

0,"101"1,"12345"11,"ABC Company"12,"John Doe"13,"123 Main St"14,""15,"Malvern"16,"PA"17,"19355"19,"UPS"21,"10"22,"GND"23,""24,"082310"25,""26,"0.00"29,"1Z1235550300000645"30," PA 193 9-05"34,"6.55"37,"6.55"38,"8.05"65,"1Z1235550300000645"77,"10"96,""97,""98

If you look closely you see its key,”value“,key,”value” The only guarantee on formatting is that each key value pair is separated by a comma, and each value will always be encased in double quotes. The main problem (the reason you cant explode it) is the poor choice of the previous coder to separate keys and values with the same character as the entries. Anyways, out of my hands. Here is a working PHP example.

    function parseResponse($response) {
    // split response into $key, $value pieces
    preg_match_all("/(.*?),\"(.*?)\"/", $response, $m);

    // loop through pieces and format
    foreach($m[1] as $index => $key) {
            $value = $m[2][$index]
                echo $key . ":" . $value;
        // this will output KEY:VALUE for each entry in the string
            }
    }

You can see the expression /(.*?),\"(.*?)\"/

Here is what I have in VB .Net

Imports System.Text.RegularExpressions
Public Class Parser
    Private Sub parseResponse(ByVal response As String)
        Dim regExMatch As Match = Regex.Match(response, "/(.*?),\""(.*?)\""/")

    End Sub
End Class
  • 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-29T10:01:02+00:00Added an answer on May 29, 2026 at 10:01 am

    You need to remove the PHP delimiters:

    Dim RegexObj As New Regex("(.*?),""(.*?)""")
    

    Also, better be more specific about what can be matched (makes the regex much more efficient):

    Dim RegexObj As New Regex("([^,]*),""([^""]*)""")
    

    Now the first group only matches characters that aren’t commas, and the second one only matches characters that aren’t quotes. Both regexes would fail, by the way, if you were to have escaped quotes in your data.

    To get all matches in a string, use

    AllMatchResults = RegexObj.Matches(response)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a web service method, this calls functionality that's pretty complex in a
this pretty much is the thing. When in tinymce I press anything that is
I have written something like this pretty easily in C# ( string GetUrl(new {
This is pretty weird. I have my Profiler open and it obviously shows that
This is pretty simple, I come from a swing/awt background. I'm just wondering what
This is pretty trivial, but I noticed on SO that instead of an offset
I'm writing a pretty complex web form using ASP.NET Dynamic Data. Several of the
I've got a pretty complex query in MySQL that slows down drastically when one
I've got a pretty complex object graph that I want to load in one
I have a report that is pretty complex, with multiple sub-reports for each item

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.