去掉[/etc/hosts]中的“[”和“]”
代码
def hostFile = "[/etc/hosts]"
println hostFile.replace("[","").replace("]","")
结果
注意
如果处理的对象不是字符串,可以用toString()方法转换为字符串
groovy replace字符串替换
阅读 181
2022-06-28
def hostFile = "[/etc/hosts]"
println hostFile.replace("[","").replace("]","")
如果处理的对象不是字符串,可以用toString()方法转换为字符串
相关推荐
精彩评论(0)