I have content in this form
$content =\"This is a sample text where {123456} and {7894560} [\'These are samples\']{145789}
\";
Two compact solutions weren't mentioned:
(?<={)[^}]*(?=})
and
{\K[^}]*(?=})
These allow you to access the matches directly, without capture groups. For instance:
$regex = '/{\K[^}]*(?=})/m';
preg_match_all($regex, $yourstring, $matches);
// See all matches
print_r($matches[0]);
Explanation
(?<={) lookbehind asserts that what precedes is an opening brace.{ matches the opening brace, then \K tells the engine to abandon what was matched so far. \K is available in Perl, PHP and R (which use the PCRE engine), and Ruby 2.0+[^}] negated character class represents one character that is not a closing brace,* quantifier matches that zero or more times(?=}) asserts that what follows is a closing brace.Reference