我正在寻找一种方法或一个正则表达式来更改一个中断标记,如:
<br style="font-size:12.8000001907349px">至:
<br>现在我正在使用这个,但不像预期的那样工作。
preg_replace("/<br\W*?\/>/", "<br>", $the_string);我怎样才能改变我的代码让它工作呢?
发布于 2015-05-21 14:06:25
只要简单一点,就像这样:
preg_replace("/<br.*?>/", "<br>", $the_string);基本上,.*?的意思是:
发布于 2015-05-21 14:07:05
将<br>标记更改为<br />标记。
这将起作用:
preg_replace("/<br.*?\/>/", "<br />", $the_string);发布于 2015-05-21 14:10:45
将这个Regex表达式用于字符串,如:
Search this: <br anykindoftext>
preg_replace("/<br\s+.*>/", "<br>", $the_string);当您使用样式搜索br标记时,需要:
Search this: <br style=“…”>
preg_replace("/<\s*br\s+style\s*=\s*".*"\s*>/", "<br>", $the_string);https://stackoverflow.com/questions/30376124
复制相似问题