ITeye博客

Groovy字符串替换一例

boogie · 2008-06-12 17:11 · Grails · Markdown

将param替换成paramValue

 

def queryContent = "select * from query where id=${param}"
def regex = '\\$\\{param\\}'
def matcher = (queryContent =~ /${regex}/)
queryContent = matcher.replaceAll('paramValue')

 

参考: http://docs.codehaus.org/display/GROOVY/Tutorial+5+-+Capturing+regex+groups

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。