• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 331
  • Last Modified:

Find values between curly brackets using preg php

I have a string

{Col 1}+{Col 2}

I would like to get:
array (
{Col 1}
{Col 2}
)

0
nbcit
Asked:
nbcit
  • 2
1 Solution
 
ddrudikCommented:

<?php
$sourcestring='{Col 1}+{Col 2}';
preg_match_all('/\{[^}]*\}/',$sourcestring,$matches);
$matches=$matches[0];
?>

Open in new window

0
 
nbcitAuthor Commented:
Fantastic!
0
 
ddrudikCommented:
Thanks for the question and the points.
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now