dmtrbskkv
@dmtrbskkv
Кодим и декодим, а иногда кино смотрим

Не работает регулярное выражение. Может я что-то упустил?

Есть такой кусок кода:
preg_replace("/\<div[^\>]*?class=\"advert \s full.*?\".*?(?=\<(p|block))/suix", "", $content);


В перемнной $content находится это:
<p><span style="font-weight: 400;">It is important to note that there are a number of different nodes that exist in the Livepeer Network. While any machine running the software and participating in the protocol is considered a node, different roles have different requirements, responsibilities, and rewards. Broadcasters are those nodes which are streaming content through the network. These nodes pay a fee for the transcoding services handled by the Livepeer Media Server. Transcoders are those nodes which provide the invaluable processing and memory resources necessary to run the server and transcode a video. The fee paid by broadcasters goes to transcoders. </span></p><div class="advert full468">
<h6><span>Advertisement</span></h6>
<div class="banner">
<div class="wpbanners" data-id="4"></div>
</div>
</div> 
<div class="advertvertical adv300x250 mobileadvert">
<h6><span>advertisement</span></h6>
<div class="content">
<div class="wpbanners" data-id="7"></div>
</div>
</div>
<p><span style="font-weight: 400;">Transcoders are elected or delegated by other nodes in the network. In addition to transcoding, these nodes also contribute to the security of the network by verifying work and distributing the new tokens produced in each block in accordance with the Livepeer Protocol. Due to their increased roles within the network, transcoders are also entitled to a greater portion of any newly created Livepeer tokens. </span></p>


На сайте https://regex101.com/ всё находится, как и через preg_match. Но если использовать функцию замены, то замена не производится - почему?
  • Вопрос задан
  • 90 просмотров
Решения вопроса 1
0xD34F
@0xD34F Куратор тега Регулярные выражения
А может, всё-таки работает, просто вы результат никак не используете? - preg_replace не меняет исходную строку, а возвращает новую.
Ответ написан
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы