I have to replace portions of a text, but just if its substrings are not contained between '<' and '>'.
For example, if I have the following text
<text color='blue'>My jeans are red</text>
<text color='red'>I am wearing a red t-shirt</text>
<text color='yellow'>I like red fruits</text>
and I want to replace the word "red" with another word, how can I replace the word in that text without replacing the ones contained between '<' and '>'? I tried to write a regular expression for that but I did not succeed...
A dumb way which I thought is to analyze all the text (char by char), see if I am inside or outside of <...> and replace the occurence of the text just if I am outside... I think there should be a smarter way!