grep

用途

使用Groovy JDK grep 方法迭代每一个指定对象的元素, 这个对象需匹配指定的"filter"属性. 过滤器可以是不同的接口,例如:一个类,或者一个正则表达式等等.

示例

Stephen King's non-fiction Books:
<g:grep in="${books}" filter="NonFictionBooks.class">
     <p>Title: ${it.title}</p>
</g:grep>

<g:grep in="${books.title}" filter="~/.*Groovy.*/"> <p>Title: ${it}</p> </g:grep>

描述

属性