小编Usm*_*sif的帖子

用于短语搜索的正则表达式

我必须在大字符串中搜索短语,长度可能为 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;
Run Code Online (Sandbox Code Playgroud)

我正在执行上述解决方法,但它不能满足所有情况。

当我有多个短语时我必须做什么,我想linq在这种情况下使用,例如:

bool success = Regex.Match(message,  **arrayofstrings**).Success;
Run Code Online (Sandbox Code Playgroud)

c# regex linq pattern-matching phrase

3
推荐指数
1
解决办法
1万
查看次数

标签 统计

c# ×1

linq ×1

pattern-matching ×1

phrase ×1

regex ×1