Sample text:
<title>Машины волосы мягкие и шелковистые потому что Маша пользуется Head & Shoulders</title> Маша уже 10 лет пользуется Head & Shoulders и она очень довольна. <!-- А это еще один title в конце документа --> <title>Машины волосы мягкие и шелковистые потому что Маша пользуется Head & Shoulders</title>
You need a regular expression that finds the words Machines and Masha between the title tags, while not performing a search in the rest of the text.
This is needed to further replace the words:Машины
→ Олены
Маша
→ Оля
I use PHP (PCRE) .
That's what happened with me:
/(?<=<title>)(?:.*)(Машины|Маша)(?:.*)(?=<\/title>)/ui
, but this regular expression finds only the word Masha :