Jump to content

Matching place holders starting/ending with {{ }}


Recommended Posts

Hi All,

 

I have been haing problems getting a regular expression working to find all matches of the following pattern burried inside XHTML markup inside a variable.

 

{{param1:123_xyz^param2:xyx^param3:123}}

 

I need to match all place holders like the above, including the curly brackets at the start and end.  The params inside can and will vary each and every time and contain mainly alphanumerical characters but also carrats/underscores/colons etc.

 

Could anyone possibly give me some guidance please?

 

Kind regards,

Brick...

 

Is it sufficient to match all {{...}} blocks?

 

If so:

<?php
$sourcestring="{{param1:123_xyz^param2:xyx^param3:123}}";
preg_match_all('/\{\{.*?\}\}/s',$sourcestring,$matches);
echo "<pre>".print_r($matches,true);
?>

$matches Array:
(
    [0] => Array
        (
            [0] => {{param1:123_xyz^param2:xyx^param3:123}}
        )

)

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.