我只是尝试(徒劳地)在循环期间删除单词“at”的所有实例。
Pattern atPattern = Pattern.compile(".*\\bat\\b.*");
String input = "at Pat's attic a fat cat catcher at patted at"
// required output "Pat's attic a fat cat catcher patted"
output = input.replace(atPattern.pattern(), " ");
output= input.replaceAll(".*\\bat\\b.*", " ");
Matcher atMatcher = atPattern.matcher(input);
output = atMatcher.replaceAll(" ");
// Starting to clutch at straws now...
Matcher atMatcher = Pattern.compile(".*\\bat\\b.*").matcher(input);
output = atMatcher.matcher(input).replaceAll(" ");
output = atPattern.matcher(input).replaceAll(" ");
我也尝试了上述许多其他组合,但我无法获得我想要的输出......
请你能让我摆脱我的痛苦..