【发布时间】:2017-08-12 17:04:57
【问题描述】:
我目前有匹配的代码
$data=["as much as I like oranges, I like bananas better",
"there's no rest for the wicked",
"the further I move from my target, the further I get",
"just because I like that song, does not mean I will buy it"];
if (stripos($data[1], 'just because I') !== false) {
$line=str_ireplace('just because I','*'.just because I.'*',$data[1]);
break;
}
这种方式只匹配包含该文本的任何句子。但我想要它做的是匹配一个通配符,这样它就可以检测一个句型。例如,它可以检测到:
"just because I... (<<any text in between>>) ...does not mean..."
希望这是可以理解的。它还需要匹配文本在句子中出现的位置,并通过在开头和结尾添加 * 来标记它。
【问题讨论】:
标签: php regex preg-match wildcard strpos