alexfernandez/prototypes · string.js
javascript logo
function(find, replace)
{
	if (util.isRegExp(find))
	{
		return this.replace(find.addOptions('i'), replace);
	}
	if (typeof find != 'string')
	{
		return null;
	}
	if (!this.containsIgnoreCase(find)) return this;
	var newCase = new RegExp(find, 'i');
	return this.replace(newCase, replace);
}
Similar code snippets
1.
alexfernandez/prototypes · string.js
Match rating: 74.25% · See similar code snippets
javascript logo
function(find, replace)
{
	if (typeof find == 'string')
	{
		if (!this.contains(find)) return this;
		return this.split(find).join(replace);
	}
	if (util.isRegExp(find))
	{
		return this.replace(find.makeGlobal(), replace);
	}
	return this.replace(find, replace);
}
2.
puranjayjain/gulp-replace-frommap · index.js
Match rating: 61.63% · See similar code snippets
javascript logo
function getIndexOf(string, find) {
    // if regex then do it regex way
    if(XRegExp.isRegExp(find)) {
      return string.search(find);
    } else {
      // normal way
      return string.indexOf(find);
    }
  }
3.
wardlem/lambdash · Str.js
Match rating: 61.45% · See similar code snippets
javascript logo
function(find, replace, str){
    return String.prototype.replace.call(str, find, replace);
}
4.
Cerealkillerway/versionUpdater · version.js
Match rating: 60.92% · See similar code snippets
javascript logo
function replaceAll(string, find, replace) {
    return string.replace(new RegExp(escapeRegExp(find), 'g'), replace);
}
5.
cloudfour/core-hbs-helpers · replaceAll.js
Match rating: 60.42% · See similar code snippets
javascript logo
function replaceAll (input, find, replace) {
  let regex = new RegExp(find, 'g');
  return input.toString().replace(regex, replace);
}
6.
jffry/lb-include · index.js
Match rating: 60.31% · See similar code snippets
javascript logo
function replaceAll(str, find, replace, caseInsensitive)
{
    if (find === null || find === (void 0))
    {
        return str;
    }
    if (replace === null || replace === (void 0))
    {
        replace = '';
    }
    find = String(find);
    replace = String(replace).replace(/\$/g, '$$$$'); //$ has special meaning in RHS of regexes, escape with $$
    var findRegex = new RegExp(find.replace(/([\\\^\$\{\}\[\]\(\)\.\*\+\?\|])/g, '\\$&'), caseInsensitive ? 'gi' : 'g');
    return str.replace(findRegex, replace);
}
7.
pvtruong/excel-report · excelReport.js
Match rating: 58.5% · See similar code snippets
javascript logo
function replaceAll(string, find, replace) {
  
  if(!string || !find) return "";
  if(underscore.isArray(replace) || underscore.isObject(replace)){
	  return string.replace(new RegExp(escapeRegExp(find), 'g'), "");
  }
  return string.replace(new RegExp(escapeRegExp(find), 'g'), replace);
}
8.
Nike-Inc/lambda-logger-node · strings.js
Match rating: 58.18% · See similar code snippets
javascript logo
function regexRedactor (find) {
  // force global replace
  const findAll = new RegExp(find.source, 'g')
  return val => replaceAllRegex(val, findAll, REDACTION)
}
9.
anatolsommer/zocci · zocci.js
Match rating: 57.91% · See similar code snippets
javascript logo
function(key) {
    if (find && find instanceof RegExp) {
      return !!find.exec(key);
    } else {
      return key.substr(0, String(find).length)===String(find);
    }
  }
10.
lihongxun945/jquery-weui · hammer.js
Match rating: 55.82% · See similar code snippets
javascript logo
function inArray(src, find, findByKey) {
    if (src.indexOf && !findByKey) {
        return src.indexOf(find);
    } else {
        var i = 0;
        while (i < src.length) {
            if ((findByKey && src[i][findByKey] == find) || (!findByKey && src[i] === find)) {
                return i;
            }
            i++;
        }
        return -1;
    }
}