我只是使用php正则表达式来过滤数据。我想使用正则表达式检测‘60的结果1- 20’,然后从$content中删除数据
$content="We have Results 1 - 20 of 60 some blah blah blah";
$content = preg_replace("/regular-expression/", " ", $content);这里的预期输出是:We have some blah blah blah
有什么想法吗?
发布于 2013-03-19 00:10:32
简而言之,这里有一个解决方案
$content="We have Results 1 - 20 of 60 some blah blah blah";
$content = preg_replace("/(Results)(\\s+)(\\d+)(\\s+)(-)(\\s+)(\\d+)(\\s+)(of)(\\s+)(\\d+)/", " ", $content);发布于 2013-03-19 00:11:44
您可以使用此正则表达式
$content = preg_replace("/\s*results\s+\d+\s+-\s+\d+\s+of\s+\d+\s*/i", " ", $content);删除Results 1 - 20 of 60。
发布于 2013-03-19 00:13:53
您可以通过
<?php
$str="We have Results 1 - 20 of 60 some blah blah blah";
echo preg_replace("/(Results)(\\s+)(\\d+)(\\s+)(-)(\\s+)(\\d+)(\\s+)(of)(\\s+)(\\d+)/", " ", $str);
?>输出
We have some blah blah blahhttps://stackoverflow.com/questions/15481458
复制相似问题