Hello everyone. I am a novice programmer and so far everything is not just given. We need to solve this problem. Given a variable with text. It has tags that define oblique text. <em> and <i>. How to highlight in red what is between these tags? How to do this if I search for the tag position number I know. But this is a very long code. And how to do it in a loop? So if the text changes, all the same, everything between these tags remains red? But how ... It does not work. Help, please. Here is an example of the text.
$ x = 'Some scientists believe that <em> dreams, </ em> are probably a selection of <i> neurons of unnecessary </ i> material - a kind of cleaning. If so, then why does so-called mental garbage have feedback through <em> memory and can be restored? </ em> Brain cells are still smarter. Dreams deserve <i> our attention, otherwise we could not </ i> remember them. Everything has some basis. <Em> If we assume that we are having dreams, predictions or dreams, </ em> solving problems, <i> what their purpose can be? </ I> The highest priority of our nerve cells is ensuring the survival of the individual and the human race as a whole. If you look at dreams from this point of view, you can make a big score. Your neurons </ em> through the mechanism of dreams <i> can serve as a mirror for you, saying: </ i> "Look at yourself, how you react. It's stress. <Em> You harm yourself, you shorten your life. </ I em> you need to change the behavior. " That is why attention should be paid to <i> dreams. What do they really mean by </ i> trying to warn you against falling into <em> a possible stressful situation? Sometimes it is useful to assume that every person from your dream </ em> is a reflection of one of the faces of you. Neighbor, brother, father, dog <i> - can they not be the embodiment of your good neighborliness, </ i> of your brotherly, fatherly or animal nature? <em> Think which parties you need more positive control. </ em> ';