http://java.sun.com/j2se/1.4.2/docs/api/java/util/regex/Pattern.html对不起上面说错了 应该是双斜线转义 "\\" string的replaceAll用到了regex包里的功能 regex里面 $ 代表 The end of a line 所以必须escape掉java.lang.String public String replaceAll(String regex, String replacement) Replaces each substring of this string that matches the given regular expression with the given replacement. An invocation of this method of the form str.replaceAll(regex, repl) yields exactly the same result as the expression java.util.regex.Pattern.compile(regex).matcher(str).replaceAll(repl)
单"\"
应该是双斜线转义 "\\"
string的replaceAll用到了regex包里的功能
regex里面 $ 代表 The end of a line 所以必须escape掉java.lang.String
public String replaceAll(String regex,
String replacement)
Replaces each substring of this string that matches the given regular expression with the given replacement.
An invocation of this method of the form str.replaceAll(regex, repl) yields exactly the same result as the expression
java.util.regex.Pattern.compile(regex).matcher(str).replaceAll(repl)