【发布时间】:2023-04-01 23:16:01
【问题描述】:
如何在 groovy 中同时用 ) 替换逗号和右括号? 我尝试用双转义替换所有
value = "('cat','rat',',')";
//Replace ,') with )
value = value.replaceAll('\\,')',')');
尝试了这些没有运气 How can I replace a string in parentheses using a regex?
How to escape comma and double quote at same time for CSV file?
【问题讨论】:
-
如果您想从字符串的开头和内部删除所有等于
','的值,请尝试value.replaceAll("(,|^)','", "")。