一般是写java和js代码时形成的混淆,js使用replace去替换,如:经常使用去空方式,java
String.prototype.trim = function() { return this.replace(/(^\s*)|(\s*$)/g, ""); }
因此写java时有可能犯错,好比 String str = "as2131qwq", 若是咱们想去掉str中的数字,很容易写成:this
str.replace("[0-9]","");
翻看jdk, replace只作简单字符替换,所以该使用replaceAll 。spa
犯过一次错,在此记录一下。prototype