[英]Regex. How to process all HTML tags in one line?
I written PHP script which transform all inline CSS in HTML tags to classes https://gist.github.com/iBars/aa52c6119e53908c91ac553aeba229e0 我编写了PHP脚本,将HTML标记中的所有内联CSS转换为类https://gist.github.com/iBars/aa52c6119e53908c91ac553aeba229e0
But it correctly process only that tags, which only one on the line. 但是,它只能正确处理该标记,而该标记只有一个。
[OK] <div style="width: 50%;">123</div>
[确定] <div style="width: 50%;">123</div>
[BROKEN RESULT] <div style="width: 50%;">123 <span style="font-size: 24px;">456</span> 789</div>
[失败的结果] <div style="width: 50%;">123 <span style="font-size: 24px;">456</span> 789</div>
How to make my script process multiple tags in line? 如何使我的脚本在线处理多个标签?
Solved by using regex below while replace in Notepad++ 在记事本++中替换时通过使用以下正则表达式解决
From: >([^\\r])
发件人: >([^\\r])
To: >\\r\\n$1
至: >\\r\\n$1
This code will force all HTML opened tags move on new line. 此代码将强制所有打开的HTML标签在新行上移动。 Then I running my script, getting result and use online HTML-formatter/-beautifier tool on it for removing uglification from regex above 然后我运行我的脚本,获取结果并在上面使用在线HTML格式/美化工具从上面的正则表达式中删除丑陋
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.