JavaScript实现startWith、endWith效果函数 利用正则表达式实现:
String.prototype.endWith=function(str){ var reg=new RegExp(str+"$"); return reg.test(this); }