繁体   English   中英

java - 如何从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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM