匹配整个单词但忽略正则表达式中的特殊字符

时间:2017-11-28 17:10:49

标签: regex

我希望匹配整个词组但忽略字符-:

例如:

Walmart Superstore - match

Walmart: Superstore - match

Walmart - Superstore - match

Walmart -  no match

dkfjsjdf - no match

Superstore - no match

我如何在正则表达式中执行此操作?

1 个答案:

答案 0 :(得分:1)

根据您的示例,您可以像Walmart[\s:-]+Superstore一样执行此操作。

https://regex101.com/r/epqiXO/1