groovy replace字符串替换 去掉[/etc/hosts]中的“[”和“]”代码def hostFile = "[/etc/hosts]"println hostFile.replace("[","").replace("]","")结果注意如果处理的对象不是字符串,可以用toString()方法转换为字符串 Groovy 2024-01-28 147 点赞 2 评论 222 浏览