I tried for 2 hours, but I can't properly manage regex. I would like to replace all html comments with a string, but only if the tag is immediately applied to the NOT line <br>.
<br>
I already have a job that already works well to remove all html comments from a string:
preg_replace('/<!--.*?-->/s', '', $str);
I try to add so that the comment is NOT replaced if a tag comes to him immediately <br>. I thought something like this (obviously wrong), but I can’t wrap myself around it:
preg_replace('/<!--.*?-->(?!<br>)/s', '', $str);
Any guidance is appreciated.
, , , , <!--, , .*?, , -->, <br>, .
<!--
.*?
-->
, , .*? -->. (?:(?!-->).)* , :
(?:(?!-->).)*
'~<!--[^-]*(?:-(?!->)[^-]*)*-->(?!<br>)~s'
regex
[^-]*(?:-(?!->)[^-]*)* 0+, - ([^-]*), 0+ - -> (. -(?!->)), 0+ -.
[^-]*(?:-(?!->)[^-]*)*
-
[^-]*
->
-(?!->)
(?:(?!-->).)* (.), --> ((?!-->)), (*).
.
(?!-->)
*
Source: https://habr.com/ru/post/1653653/More articles:Android BLE: "Scan failed, application registration error for UUID" - androidКак экспортировать изображения в виде видео в Swift? - iosTarget.Net 4.5 in VS2015, but am I allowed to use C # 6 functions? - c #Angular Side-to-Side Sliding Long Text Directive - javascriptConditional join in Hive - hadoopHow to expand the view from the box layout? - androidCompiling String Literals - c ++ASP.NET MVC Web API Result Caching - c #Entity Framework Request multiple collections - c #Identification of logically repeated rows in a table - sqlAll Articles