Я работаю над проектом SEO на PHP и хочу выделить определенное слово в фрагменте HTML-контента. Модификация должна быть на определенном теге, т.е. теге <p>
, и никаких других, особенно. теги заголовков (<h1>
, <h2>
и т. д.)
Кроме того, я не хочу влиять на какие-либо атрибуты тегов HTML, если они содержат конкретное слово для замены.
<h1>A **SPECIFIC_WORD** information</h1>
<p><img src="some_image.jpg" title="**SPECIFIC_WORD** some other words" />
Lorem Ipsum is simply dummy text of the printing and typesetting industry.
Lorem Ipsum has been the industry's standard dummy text ever since the
1500s, when an unknown printer took a galley of type and scrambled it to make
a type specimen book. It has survived not only five centuries, but also the leap
into electronic typesetting, remaining <a href="#" title="some other words
**SPECIFIC_WORD** other words">essentially unchanged</a>. It was popularised
in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages,
and more recently **SPECIFIC_WORD** with desktop publishing software like Aldus
PageMaker including versions of Lorem Ipsum.</p>
Как вы видите, SPECIFIC_WORD встречается во многих местах, но я хочу сопоставить и изменить SPECIFIC_WORD, который содержится в тексте абзаца, а не в каком-либо атрибуте тега или теге заголовка.