我正在编写一个正则表达式来匹配每个出现的“日本”并将其替换为“日本”..为什么下面的不起作用?并且“日本”可以在一个句子中出现多次,也可以在句子中的任何地方出现。我想替换所有出现
public static void testRegex()
{
String input = "The nonprofit civic organization shall comply with all other requirements of section 561.422, japan laws, in obtaining the temporary permits authorized by this act.";
String regex = "japan";
Pattern p = Pattern.compile(regex);
Matcher m = p.matcher(input);
System.out.println(input.matches(regex));
System.out.println(input.replaceAll(regex, "Japan"));
}