I have a text file like so
{word} definition
{another word} another definition {word} they don't have to be on different lines
The regex I was using was
$regex = '/\{([a-z]+?)\}(.+?)\{/i';
This however, causes problems in that it swallows the last brace {, and then it won't match the next { in the next word.
To demonstrate, I did this for debugging purposes
echo preg_replace($regex, '<b style="background-color: red;">$1</b><b style="background-color: yellow;">$2</b>', $content);
Here is an example of my output (notice the opening brace in the next word isn't there, therefore it is not matched in the regex)
<b style="background-color: red;">shrub</b><b style="background-color: yellow;"> Multi stemmed woody plant</b>Abaxial} side or face away from the axis
How can I amend my regex to get this to work? Thank you
EDIT
Many thanks for your answers. I've changed my regex like so
$regex = '/\{([a-z\-\s]+?)\}([^\{]+)/i';
I'll also look into the lookahead articles.