我必须搜索大字符串中的短语,长度可能在500或600或更大,现在我必须检查短语是否存在
phrase = "Lucky Draw"
big string1 = "I'm looking for Lucky Draw a way to loop through the sentences and check"
big string1 = "I'm looking for specialLucky Draw a way to loop through the sentences and check"
big string3 = "I'm looking for Lucky Draws a way to loop through the sentences and check"
bool success = Regex.Match(message, @"\bLucky Draw\b").Success;
我正在执行上述解决方法,但不能满足所有情况。
当我有多个短语时该怎么办,在这种情况下,我想使用linq
>
bool success = Regex.Match(message, **arrayofstrings**).Success;
答案 0 :(得分:0)
您可以使用循环从短语数组中构建一个\b(phrase one|phrase two|phrase three|etc)\b
的大型正则表达式,然后使用该正则表达式与您的字符串进行匹配。