Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我的代码中有一个这个列表:
def officers = [[name:'Mark', surname: 'Pen'], [name:'Maria', surname: 'Charlote']]
现在可以搜索此列表吗?我的意思是
def found = officers.findNameLike('%Mar%')
因此它将返回这两个值,因为它们的名称上有 MAR 字符。
甚至可能吗?或者他们无论如何都在这附近?
我不知道 Groovy,但是通过快速的谷歌,像这样的非笨重的东西应该可以工作:
def found = officers.findAll { it.name =~ /Mar/ }