![](/img/trans.png)
[英]how to get the array of strings that are inside curly braces in the source string in java
[英]How to remove content inside curly braces{} along with the braces from a string in java?
例如我有一个字符串:-
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.
我在java中尝试了几个正则表达式来解决这个问题。 我得到了正确的{$geoAddress}
, String message = High PM2.5 在 {$coordinate} 中找到,地址是{$geoAddress}
,解决方案在{$solutionCoordinate}
,地址是{$solutionAddress}
。
message = message.replaceAll("\\{[^}]*\\}", "");
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.