replaceAll

本意是要把“. net”变成".net",下面的语句有什么问题吗?


String ss = "www network";
System.out.println(ss.replaceAll(". net", ".net"));


问题:

1. "."表示任意字符,

2. 要在"."之前和net之后有空格


ss.replaceAll(" \\. net ", " .net ")

你可能感兴趣的:(replaceAll)