[英]How do I java regex find and replace
什么是用于删除括号及其之间所有内容的正则表达式?
input = "hello world (this is a test1) (test 2) hello";
output = "hello world hello";
我试过了:
str.replaceAll("//(.*?//)", "");
您正在使用正斜杠字符转义(
和)
特殊字符。 您需要使用反斜杠:
String output = input.replaceAll("\\(.*?\\)", "");
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.