将param替换成paramValue
复制代码
1
2
3
4def 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
最后
以上就是俏皮水杯最近收集整理的关于Groovy字符串替换一例的全部内容,更多相关Groovy字符串替换一例内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复