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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T00:28:47+00:00 2026-05-27T00:28:47+00:00

Satisfactory that is to not go into functions that eat much time. Format of

  • 0

Satisfactory that is to not go into functions that eat much time.

Format of the data:
It is basically similar to the HTML tag parameters, but not quite.

<name1=value1 name2=value2 [here can be any whitespace characters]
33=55 "name with spaces and ="="value with spaces and '" '"title"'="can't" "in
names"="and
values can be tabs and new lines"
double"and_single'quotes=are_allowed_in_names_and_values_if_there_is_no_whitespace_in_it
"escaping is ""sql-like"""='the same with ''single quotes'''
`third option`=`are "backticks" that also can be ``escaped```>

Is this format called somehow ? I ‘invented’ it myself but I highly doubt that no one came up with this idea before, maybe it (or very similar format, for example with slash escaping) already has a parsing function in php ?

If not, how to write my own, using regexes, string operations, some kind of buffers, accumulators ? I’ve never written any parser myself yet.

  • 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-27T00:28:47+00:00Added an answer on May 27, 2026 at 12:28 am

    Try something like this:

    $in = <<<BLOCK
    name1=value1 
    
    name2=value2 [here can be any whitespace characters]
    
    33=55 
    
    "name with spaces and ="="value with spaces and '" 
    
    '"title"'="can't" 
    
    "in names"="and
      values can be tabs and new lines"
    
    double"and_single'quotes=are_allowed_in_names_and_values_if_there_is_no_whitespace_in_it
    
    "escaping is ""sql-like"""='the same with ''single quotes'''
    
    `third option`=`are "backticks" that also can be ``escaped```
    BLOCK;
    
    $string = "(?:                    # open non-capture group
                 \"(?:\"\"|[^\"])+\"  # match a double quoted string
               | '(?:''|[^'])+'       # OR match a single quoted string
               | `(?:``|[^`])+`       # OR match a back-ticked string
               )                      # close non-capture group
              ";
    
    $key    = "(                      # start capture group 1
                 $string              # match any string
               | [^=\s]+              # OR match one or more chars other than '=' and space-chars
               )                      # end capture group 1
              ";
    
    $value  = "(                      # start capture group 2
                 $string              # match any string
               | [^\r\n]+             # OR match one or more chars other than '=' and space-chars
               )                      # end capture group 2
              ";
    
    $regex = "/$key=$value/x"; // combine the patterns
    
    preg_match_all($regex, $in, $matches);
    
    $key_value_pairs = sizeof($matches[0]);
    
    for($index = 0; $index < $key_value_pairs; $index++) {
      echo "===============================================\n" . 
           "KEY:\n" . $matches[1][$index] . "\n" .
           "VALUE:\n" . $matches[2][$index] . "\n";
    }
    

    which will print the following:

    ===============================================
    KEY:
    name1
    VALUE:
    value1 
    ===============================================
    KEY:
    name2
    VALUE:
    value2 [here can be any whitespace characters]
    ===============================================
    KEY:
    33
    VALUE:
    55 
    ===============================================
    KEY:
    "name with spaces and ="
    VALUE:
    "value with spaces and '"
    ===============================================
    KEY:
    '"title"'
    VALUE:
    "can't"
    ===============================================
    KEY:
    "in names"
    VALUE:
    "and
      values can be tabs and new lines"
    ===============================================
    KEY:
    double"and_single'quotes
    VALUE:
    are_allowed_in_names_and_values_if_there_is_no_whitespace_in_it
    ===============================================
    KEY:
    "escaping is ""sql-like"""
    VALUE:
    'the same with ''single quotes'''
    ===============================================
    KEY:
    `third option`
    VALUE:
    `are "backticks" that also can be ``escaped```
    

    Use, and maintain, at your own risk!

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

Sidebar

Related Questions

We have an application that takes real time data and inserts it into database.
I have a question that I just don't feel like I've found a satisfactory
i looked at Test C code with googletest but did not find any satisfactory
I assume that there is probably no satisfactory answer to this question, but I
I have asked a related question , but I did not get a satisfactory
Firstly there is an almost identical question but the answer is not really satisfactory.
I know this is similar to other topics, but I've not yet found a
Although this has been asked before, due to the fact that no satisfactory answer
I already asked a similar question on StackOverflow, and I got a very satisfactory
I am looking for satisfactory options for unit testing my .NET DAL classes; since

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.