brick Posted November 19, 2008 Share Posted November 19, 2008 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... Quote Link to comment Share on other sites More sharing options...
ddrudik Posted November 19, 2008 Share Posted November 19, 2008 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}} ) ) Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.