没有这个方法,我刚在浏览器里面敲了,没有提示
String.prototype.endWith = function (str) { var reg = new RegExp(str + "$"); return reg.test(this); } var test = "1234,"; if (test.endWith(",")) { alert("yes"); } else { alert("no"); }
var strs = "aaa.bbb.xls"; var arr = strs.split("."); alert(arr[arr.length - 1]);