X Tutup
Skip to content

Commit d6d83a8

Browse files
author
zhourenjian
committed
Fix bug of String#matches
1 parent fc21cb2 commit d6d83a8

File tree

1 file changed

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

1 file changed

+10
-0
lines changed

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,9 @@ String.prototype.replaceFirst = function (exp, str) {
8080
return this.replace (regExp, this.$generateExpFunction (str));
8181
};
8282
String.prototype.matches = function (exp) {
83+
if (exp != null) {
84+
exp = "^(" + exp + ")$";
85+
}
8386
var regExp = new RegExp (exp, "gm");
8487
var m = this.match (regExp);
8588
return m != null && m.length != 0;
@@ -543,5 +546,12 @@ String.instantialize = function () {
543546
return s;
544547
}
545548
};
549+
550+
if (navigator.userAgent.toLowerCase ().indexOf ("chrome") != -1) { // Google Chrome's bug
551+
String.prototype.toString = function () {
552+
return this;
553+
};
554+
}
555+
546556
} // end of String.prototype.$replace
547557
});

0 commit comments

Comments
 (0)
X Tutup