Javascript String contains(str)
String.prototype.contains = function(str) { return this.indexOf(str) > -1; };
String.prototype.contains = function (str) { return this.indexOf(str, 0) != -1; }
String.prototype.contains = function(str) { return this.toLowerCase().indexOf(str.toLowerCase()) > -1; };
String.prototype.contains = function(str) { if (typeof str !== 'string') return false; return this.indexOf(str) !== -1; };
String.prototype.contains = function(str){ var filters = str.toLowerCase().split(/[ ,_\-]+/); var tokens = this.toLowerCase().split(/[ ,\-]+/); for (var i = 0; i < filters.length; i++) { var match = false; for (var j = 0; j < tokens.length; j++) { if (tokens[j].startsWith(filters[i])) { match = true;//w w w . jav a 2s. co m break; } } if (match == false) { return false; } } return true; }
String.prototype.contains = function(str){ if(this.indexOf(str) != -1){ return true;//from ww w.j a va2 s . c o m } return false; } String.prototype.insert = function(flg, offset){ var temp_1 = this.substring(0, offset + 1); var temp_2 = this.substring(offset + 1); return temp_1 + flg + temp_2; }