为什么不能否定 Groovy 正则表达式匹配器? [英] Why can't Groovy regex matchers be negated?
本文介绍了为什么不能否定 Groovy 正则表达式匹配器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
谁能解释一下以下内容?
Can anyone explain the following?
println('x' ==~ /x/)
println('x' !=~ /x/)
结果:
true
true
推荐答案
groovy 中没有 !=~
运算符.它是 !=
和 ~
的组合.
There is no !=~
operator in groovy. It's a combination of !=
and ~
.
println('x' !=~ /x/)
相当于
println('x' != (~ /x/))
你需要的是
println(!('x' ==~ /x/))
这篇关于为什么不能否定 Groovy 正则表达式匹配器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文