Skip to content

Commit 16cf4c3

Browse files
author
zhourenjian
committed
Fixed bug that String#replaceAll/#replaceFirst does not deal "\" correctly.
1 parent 4fdd937 commit 16cf4c3

File tree

1 file changed

+2
-2
lines changed
  • sources/net.sf.j2s.java.core/src/java/lang

1 file changed

+2
-2
lines changed

sources/net.sf.j2s.java.core/src/java/lang/String.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,11 @@ String.prototype.$replace = function (c1, c2) {
2323
};
2424
String.prototype.replaceAll = function (exp, str) {
2525
var regExp = new RegExp (exp, "gm");
26-
return this.replace (regExp, str);
26+
return this.replace (regExp, str.replace (/\\\\/gm, "\\"));
2727
};
2828
String.prototype.replaceFirst = function (exp, str) {
2929
var regExp = new RegExp (exp, "m");
30-
return this.replace (regExp, str);
30+
return this.replace (regExp, str.replace (/\\\\/gm, "\\"));
3131
};
3232
String.prototype.matches = function (exp) {
3333
var regExp = new RegExp (exp, "gm");

0 commit comments

Comments
 (0)