例如我有一个字符串: -
High PM2.5 found in {$coordinate} and address is {$geoAddress} and solution found in {$solutionCoordinate} and address is {$solutionAddress}.
我想从此字符串中删除花括号中的所有内容,输出应为: -
High PM2.5 found in and address is and solution found in and address is.
答案 0 :(得分:0)
我在java中尝试了几个正则表达式来解决这个问题。我有一个正确的,
字符串消息=在{$ coordinate}中找到高PM2.5,地址为{$geoAddress}
,在{$solutionCoordinate}
中找到解决方案,地址为{$solutionAddress}
。
message = message.replaceAll("\\{[^}]*\\}", "");