我试图让输入不是模式。
SPARK_DAEMON_JAVA_OPTS="-Dspark.deploy.recoveryMode=ZOOKEEPER -Dspark.deploy.zookeeper.url=10.149.11.146:2181,10.149.11.147:2181,10.149.11.148:2181 -Dspark.deploy.zookeeper.dir=/vehicle_spark"
export SPARK_DAEMON_JAVA_OPTS
即使输入的单词与我试图将其比较的句子的顺序与输入单词的顺序不同,它也可以返回&#34;匹配找到。&#34; < / p>
答案 0 :(得分:1)
只需使用preg_match_all
即可preg_match_all("/\b{$input}\b/", "these are a lot of words that i'm trying to compare",$matchedWords);
对于多个单词:
<?php
$input= "words compare";
$pattern = str_replace(" ","|",$input);
preg_match_all("/{$pattern}/", "these are a lot of words that i'm trying to compare words",$matchedWords);
// ^this might contain multiple words, but the same as ^^ these
var_dump($matchedWords);
答案 1 :(得分:0)
$input= "words|trying|to|compare";
$count = preg_match_all('#\b('.$input.')\b#', $string, $matches);
if($count)
echo 'found word';
else
echo 'not found';