I am very new to both stackoverflow and Regexes, so please forgive the errors.
I carefully searched for a regular expression to match all text that is not between the curly braces {}, and certain words are found from this text. For example, from the following line:
$content = 'Hello world, { this } is a string with { curly brackets } and this is for testing'
I would like the search for the word this return only the second occurrence of this , because it is in an area that is not inside the curly braces. Even if I can get a regular expression to match substrings behind curly braces, things will get easier for me. I found this Regex /(}([^}]*){)/ , but cannot select the Hello world, parts Hello world, and and this is for testing , because they are not inside }{ , and it selects only the part is a string with .
I would also like to ask if it is possible to combine two Regex for one purpose, such as mine. For example, the first Regex finds strings outside of {} and the second finds certain words that are searched.
I want to use this Regex in php, and now I use a function that looks more like a hack. The goal is to find specific words that are not in {} , reliably replace them and write to text files.
Thanks in advance for your help.
source share