Php 替换<;br style="&引用&燃气轮机;与<;br>;

Php 替换<;br style="&引用&燃气轮机;与<;br>;,php,html,regex,string,Php,Html,Regex,String,我正在寻找一种方法或正则表达式来更改break标记,如: <br style="font-size:12.8000001907349px"> 致: 现在我正在使用这个,但没有按预期工作 preg_replace("/<br\W*?\/>/", "<br>", $the_string); preg\u replace(“//”、“”、$字符串); 如何更改代码以使其正常工作?请保持简单,如下所示: preg_replace("/<br.*?&

我正在寻找一种方法或正则表达式来更改break标记,如:

<br style="font-size:12.8000001907349px">

致:


现在我正在使用这个,但没有按预期工作

preg_replace("/<br\W*?\/>/", "<br>", $the_string);
preg\u replace(“//”、“
”、$字符串);

如何更改代码以使其正常工作?

请保持简单,如下所示:

preg_replace("/<br.*?>/", "<br>", $the_string);
preg\u replace(“//”、“
”、$字符串);
基本上
*?
表示:

  • *?匹配任何字符(换行符除外)
    • 量词:*?在零次和无限次之间,尽可能少的次数,根据需要扩展[lazy]

保持简单,如下所示:

preg_replace("/<br.*?>/", "<br>", $the_string);
preg\u replace(“//”、“
”、$字符串);
基本上
*?
表示:

  • *?匹配任何字符(换行符除外)
    • 量词:*?在零次和无限次之间,尽可能少的次数,根据需要扩展[lazy]


标记更改为

标记

这将有助于:

preg_replace("/<br.*?\/>/", "<br />", $the_string);
preg\u replace(“//”,“
,$字符串);

标记更改为

标记

这将有助于:

preg_replace("/<br.*?\/>/", "<br />", $the_string);
preg\u replace(“//”,“
,$字符串);
将此正则表达式用于以下字符串:

Search this: <br anykindoftext>

preg_replace("/<br\s+.*>/", "<br>", $the_string);
搜索此:
preg_replace(“//”,“
”,$字符串);
搜索带有所需样式的br标记时:

Search this: <br style=“…”>
preg_replace("/<\s*br\s+style\s*=\s*".*"\s*>/", "<br>", $the_string);
搜索此:
preg_replace(“//”,“
”,$字符串);
将此正则表达式用于以下字符串:

Search this: <br anykindoftext>

preg_replace("/<br\s+.*>/", "<br>", $the_string);
搜索此:
preg_replace(“//”,“
”,$字符串);
搜索带有所需样式的br标记时:

Search this: <br style=“…”>
preg_replace("/<\s*br\s+style\s*=\s*".*"\s*>/", "<br>", $the_string);
搜索此:
preg_replace(“//”,“
”,$字符串);
$the_string=preg_replace(“~]+/?>”,“
”,$the_string)
尝试了到目前为止的所有建议似乎都没有效果@CSKoh那么:
var\u dump($u字符串)的确切输出是什么?@Rizier123我在实际代码上尝试了这个方法,得到了正确的结果。支架校正=)
$the_string=preg_replace(“~]+/?>~”,“
”,$the_string)
尝试了到目前为止的所有建议似乎都没有效果@CSKoh那么:
var\u dump($u字符串)的确切输出是什么?@Rizier123我在实际代码上尝试了这个方法,得到了正确的结果。立场正确=)