vbarzokas/greek-utils · index.js
javascript logo
function (characters) {
			regexString = exactMatch ? characters.find : '[' + characters.find + ']';
			if (ignore) { regexString = '(?![' + ignore + '])' + regexString; }
			regex = new RegExp(regexString, 'g');
			text = text.replace(regex, characters.replace);
		}
Similar code snippets
1.
agneta/angularjs · greeklish.js
Match rating: 72.96% · See similar code snippets
javascript logo
function replaceText(text, characterMap, exactMatch) {
    var characters,
      regexString,
      regex;

    exactMatch = exactMatch || false;

    if (typeof text === 'string' && text.length > 0) {
      for (var key in characterMap) {
        characters = characterMap[key];
        regexString = exactMatch ? characters.find : '[' + characters.find + ']';
        regex = new RegExp(regexString, 'g');
        text = text.replace(regex, characters.replace);
      }
    }

    return text;
  }
2.
rajgoel/reveal.js-plugins · ruleJS.all.full.js
Match rating: 61.41% · See similar code snippets
javascript logo
function(characters) {
    if (characters == null)
      return '\\s';
    else if (characters.source)
      return characters.source;
    else
      return '[' + _s.escapeRegExp(characters) + ']';
  }
3.
golden-layout/golden-layout · zepto-extras.js
Match rating: 59.09% · See similar code snippets
javascript logo
function(str, characters){
    if (!characters && nativeTrim) {
      return nativeTrim.call(str);
    }
    characters = defaultToWhiteSpace(characters);
    return str.replace(new RegExp('\^[' + characters + ']+|[' + characters + ']+$', 'g'), '');
  }
4.
yoniholmes/grunt-text-replace · grunt-text-replace.js
Match rating: 57.32% · See similar code snippets
javascript logo
function (pattern) {
    var regexCharacters = '\\[](){}^$-.*+?|,/';
    if (typeof pattern === 'string') {
      regexCharacters.split('').forEach(function (character) {
        var characterAsRegex = new RegExp('(\\' + character + ')', 'g');
        pattern = pattern.replace(characterAsRegex, '\\$1');
      });
      pattern = new RegExp(pattern, 'g');
    }
    return pattern;
  }
5.
vkiding/jud-devtool · utilities.js
Match rating: 57.27% · See similar code snippets
javascript logo
function createPlainTextSearchRegex(query, flags)
{
    // This should be kept the same as the one in V8StringUtil.cpp.
    var regexSpecialCharacters = String.regexSpecialCharacters();
    var regex = "";
    for (var i = 0; i < query.length; ++i) {
        var c = query.charAt(i);
        if (regexSpecialCharacters.indexOf(c) != -1)
            regex += "\\";
        regex += c;
    }
    return new RegExp(regex, flags || "");
}
6.
connrs/node-encode-quoted-printable · encode-quoted-printable.js
Match rating: 57.09% · See similar code snippets
javascript logo
function encodeCharacters(characters) {
  var charCode;

  // Encode space before CRLF sequence to prevent spaces from being stripped
  // Keep hard line breaks intact; CRLF sequences
  if (characters.length > 1) {
    return characters.replace(' ', '=20');
  }

  // Encode matching character
  charCode = characters.charCodeAt(0);

  //return '=' + hexChars[((charCode >>> 4) & 15)] + hexChars[(charCode & 15)];
  return toUTF8Array(characters).map(function (c) { return '=' + zeroPad(c.toString(16).toUpperCase());  }).join('');
}
7.
NaturalNode/natural · TF_Parser.js
Match rating: 56.55% · See similar code snippets
javascript logo
function(characters) {
         var s = "";
         for (var i = 0; i < characters.length; i++) {
           s += characters[i];
         }
         return(s);
        }
8.
jecs-imperial/occam-parsers · horizontalBranch.js
Match rating: 56.29% · See similar code snippets
javascript logo
function stringFromCharactersWidth(charactersWidth, character) {
  let string = '';

  for (let index = 0; index < charactersWidth; index++) {
    string += character;
  }

  return string;
}
9.
create-conform/allume · string.js
Match rating: 56.1% · See similar code snippets
javascript logo
function trim(str, characters, flags) {
                    characters = characters != null && characters != ""? characters : " ";
                    flags = flags || "g";
                    if (typeof str !== "string" || typeof characters !== "string" || typeof flags !== "string") {
                        throw new TypeError("Argument must be string.");
                    }
    
                    if (!/^[gi]*$/.test(flags)) {
                        throw new RangeError("Invalid flags supplied '" + flags.match(new RegExp("[^gi]*")) + "'.");
                    }
    
                    characters = escapeRegex(characters);
    
                    return str.replace(new RegExp("^[" + characters + "]+|[" + characters + "]+$", flags), '');
                }
10.
MikeKovarik/rollup-plugin-notify · index.js
Match rating: 55.57% · See similar code snippets
javascript logo
function calculateCountOfReplacementChar(string, replaceByChar = ' ') {
	var characters = 0
	string
		.split('')
		.forEach(char => {
			var size = charSizes.get(char) || 1
			characters += size
		})
	// All sizes were measured against space char. Recalculate if needed.
	if (replaceByChar !== ' ')
		characters = characters / charSizes.get(replaceByChar)
	return Math.round(characters)
}