[英]Regex in Java to deal with control sequences
I have Strings like我有像这样的字符串
'(123-inf]\\\\\'
'\\\'\(12.3-430-1]\\\'
'\\\'\(inf-12.23)\\\\'
'123-123.3]
How to remove anything preceded by (
- including (
and anything followed by either )
or ]
- including both character.如何删除前面有(
- 包括(
以及后面跟着)
或]
任何内容 - 包括这两个字符。
使用全部replaceAll
string.replaceAll("^.*\\(|[)\\]].*", "");
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.