I am very new to both stackoverflow and Regexes so please forgive mistakes.
I have been searching thoroughly for a Regex to match all text that is not between curly brackets {} and from that text find certain words. For example from the following string:
$content = 'Hello world, { this } is a string with { curly brackets } and this is for testing'
I would like the search for word this
to return only the second occurrence of this
because its in the area which is not inside curly brackets.
Even if I can get a Regex to match the substrings outside the curly brackets, things get simplified for me. I found this Regex /(}([^}]*){)/
but it cannot select the parts Hello world,
and and this is for testing
because these are not inside }{
and it only selects is a string with
part.
Also I would like to ask if it is possible to combine two Regex for a single purpose like mine. For example the first Regex finds strings outside {}
and second finds specific words that are searched for.
I want to use this Regex in php and for now I am using a function which is more like a hack. The purpose is to find specific words that are not in {}
,replace them reliably and write to text files.
Thanks in advance for your help.