我有一根绳子 Hello java [to:] how are you?
. 我想要输出像: Hello java how are you?
.
请帮助使用java正则表达式。我的代码是:
String data = "Hello java [to:sdsdsd.kdsd] how are you?";
Pattern pattern = Pattern.compile("\[to:]");
Matcher matcher = pattern.matcher(data);
matcher.find();
System.out.println(matcher.group(1))
1条答案
按热度按时间atmip9wb1#
当我使用data.replaceall(“[to:(.*)]”,“”)时,它工作正常