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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T15:29:43+00:00 2026-05-16T15:29:43+00:00

I have to parse this template file ($html) : {$myFirstVariable} {$myMainVar:MYF1,x\:x\,x,2:MYF2:MYF3,false} {$myLastVariable:trim} Following, my

  • 0

I have to parse this template file ($html) :

{$myFirstVariable}
{$myMainVar:MYF1,"x\:x\,x",2:MYF2:MYF3,false}
{$myLastVariable:trim}

Following, my php parser :

$regexp = '#{\$(?<name>.+?)(\:(?<modifiers>.+?))?}#';

preg_replace_callback($regexp, 'separateVariable', $html);

function separateVariable($matches) {
    $varname = $matches['name'];

    print $varname."\n";

    if (isset($matches['modifiers'])) {
        $modifiers = $matches['modifiers'];

        $modifiers = preg_split('#(?<!\\\):#', $modifiers);
        $parsed = array();

        foreach ($modifiers as $modifier) {
            $modifier = preg_split('#(?<!\\\),#', $modifier);
            $parsed[array_shift($modifier)] = $modifier;
        }

        // parsed[myFuncName] = Array(2ndArg, 3rdArg)

        print_r($parsed);
    }

    print "\n";
}

All working except i’ve to escape ‘:’ and ‘,’ in {$myMainVar:…} with an ‘\’.

Do you have any solution to free me up of ‘\’ ?

Thanks.

  • 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-16T15:29:44+00:00Added an answer on May 16, 2026 at 3:29 pm

    Regular expression can’t return nested array, besides, what you are trying to seems more that text processing (substr, explode..) than having to use regular expression. Also, your example doesn’t make it clear how is the standard processing of the input works.

    I suggest: Building a recursive function that deals with the logic of your unserialiing process, that function will use switch cases and string manipulation functions.

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

Sidebar

Related Questions

I have this tag into my html file: {{block:my_test_block}} {{news:my_test_block2}} I need to parse
I have to parse a big HTML file, and Im only interested in a
Normally the XML files I have to parse are like this: <row id=1> <title>widget<title>
I have string as abvd.qweqw.sdfs.a=aqwrwewrwerrew . I need to parse this string and get
I have a JSON which I get from web application. I try this parse
http://www.taxmann.com/TaxmannWhatsnewService/Services.aspx?service=gettopstoriestabnews This is my web service I have to parse and store all value
I have this JSON http://www.progmic.com/ielts/retrive.php that I need to parse. When I do it
Hi I have this code to parse JSON on JQUERY var json_text2 = $.parseJSON('{data:[[1340650436,2.00000],[1340736844,4.00000]],label:Waist
I have this array, that I want to parse into javascript. $offerText[] = (
I have been trying to parse the bottom table on this site using different

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.