如何在Groovy中的字符串中为两个不同的单词进行正则表达式?当我查找一个字符串时,我只能让它工作。
def r = "This is a line that only contains LookForMe and nothing else"
def result = r =~ ('LookForMe' || 'AndMeToo')
assert result instanceof Matcher
if (result) ...
我希望能够找到' LookForMe'或者' AndMeToo'如果任何一种情况是“真实的”,那就执行一项行动。
答案 0 :(得分:1)
def r = "This is a line that only contains LookForMe and nothing else"
def result = (r =~ /.*LookForMe.*|.*AndMeToo.*/)
if(result) ...