0
点赞
收藏
分享

微信扫一扫

groovy replace字符串替换

Greatiga 2022-06-28 阅读 181

去掉[/etc/hosts]中的“[”和“]”

代码

def hostFile = "[/etc/hosts]"
println hostFile.replace("[","").replace("]","")

结果

groovy replace字符串替换_groovy

注意

如果处理的对象不是字符串,可以用toString()方法转换为字符串


举报

相关推荐

0 条评论