I need to extract text in curly braces but only if the first word within them is a "allowed" word. for example the following text:
awesome text,
a new line {find this braces},
{find some more} in the next line.
Please {dont find} this ones.
in this simple example "find" stands for a allowed word
my attemp:
$pattern = '!{find(.*)}!is';
$matches = array();
preg_match_all( $pattern, $text, $matches, PREG_SET_ORDER );
returns a weird result (print_r):
Array
(
[0] => Array
(
[0] => {find this braces},
{find some more} in the next line.
Please {dont find}
[1] => this braces},
{find some more} in the next line.
Please {dont find
)
)
while working fine without the "find" in the pattern (but then the one with "dont" is found, too.
What may be the cause for this?