candreoliveira/ngMask · ngMask.js
javascript logo
function getRegex(index) {
          var currentRegex;

          try {
            currentRegex = regex[index] ? regex[index].source : '';
          } catch (e) {
            throw e;
          }

          return (new RegExp('^' + currentRegex + '$'));
        }
Similar code snippets
1.
instana/nodejs-sensor · secrets.js
Match rating: 68.21% · See similar code snippets
javascript logo
function(regexString) {
      try {
        // The Java regex matcher only matches if the whole string is a match, JS RegExp.test matches if the regex is
        // found as a substring. To achieve parity with the Java functionality, we enclose the regex in '^' and '$'.
        if (regexString.indexOf('^') !== 0) {
          regexString = '^' + regexString;
        }
        if (regexString.indexOf('$') !== regexString.length - 1) {
          regexString += '$';
        }
        regexes.push(new RegExp(regexString));
      } catch (e) {
        logger.warn(
          'Received invalid regex from agent: %s - this regex will not be used for removing secrets',
          regexString
        );
      }
    }
2.
fgnass/domino · select.js
Match rating: 67.54% · See similar code snippets
javascript logo
function(regex, name, val) {
  regex = regex.source;
  regex = regex.replace(name, val.source || val);
  return new RegExp(regex);
}
3.
wikimedia/parsoid · WikiConfig.js
Match rating: 66.4% · See similar code snippets
javascript logo
function buildLinkNeighbourRegex(string, isTrail) {
		var regexResult = string.match(stripRegex);

		if (regexResult !== null) {
			regexResult = regexResult[1].replace(/\(\.\*\??\)/, '');
			regexResult = convertCodePoints(regexResult);
		}

		if (regexResult === '()') {
			// At least zh gives us a linktrail value of /^()(.*)$/sD, which
			// would match anything. Refuse to use such a non-sense regexp.
			return null;
		}

		if (isTrail) {
			regexResult = '^' + regexResult;
		} else {
			regexResult += '$';
		}

		try {
			return new RegExp(regexResult);
		} catch (e) {
			console.error(e);
			return null;
		}
	}
4.
GoIncremental/gi-util · gi-util.js
Match rating: 66.24% · See similar code snippets
javascript logo
function exec(string, regex) {
        if (typeof regex === 'string' || regex instanceof String) {
            regex=new RegExp(regex);
        }

        if (regex instanceof RegExp) {
            return regex.exec(string);
        }
        else if (regex && Array.isArray(regex)) {
            return regex.reduce(function (res, item) {
                return (!!res) ? res : exec(string, item);
            }, null);
        }
        else {
            return null;
        }
    }
5.
eclipse/orion.client · textStyler.js
Match rating: 65.92% · See similar code snippets
javascript logo
function(current) {
				var regex = current.regex || current.regexBegin;
				regex.lastIndex = regex.oldLastIndex;
			}
6.
syntaxhighlighter/syntaxhighlighter-regex · xregexp.js
Match rating: 65.59% · See similar code snippets
javascript logo
function(regex) {
        var result;

        if (!XRegExp.isRegExp(regex)) {
            // Use the native `RegExp` rather than `XRegExp`
            regex = new RegExp(regex);
        } else if (regex.global) {
            result = nativ.match.apply(this, arguments);
            // Fixes IE bug
            regex.lastIndex = 0;

            return result;
        }

        return fixed.exec.call(regex, toObject(this));
    }
7.
quorrajs/Positron · Route.js
Match rating: 65.0% · See similar code snippets
javascript logo
function (key, regex) {
    if (!_.isString(regex)) {
        throw new Error('Routing requirement for ' + key + ' must be a string.');
    }

    if ('' !== regex && '^' === regex[0]) {
        regex = regex.substr(1); // returns false for a single character

        if (regex === "")
            regex = false;
    }

    if ('$' === regex.substr(-1)) {
        regex = regex.slice(0, -1);
    }

    if ('' === regex) {
        throw new Error('Routing requirement for ' + key + ' cannot be empty.');
    }

    return regex;
}
8.
tandrewnichols/indeed · base.js
Match rating: 64.5% · See similar code snippets
javascript logo
function(regex) {
  // If the regex is a string, convert it to a RegExp
  if (typeof regex === 'string') {
    regex = new RegExp(regex);
  }

  return this._compare(function(val) {
    return regex.test(val);
  });
}
9.
ccxt/ccxt · transpile.js
Match rating: 64.23% · See similar code snippets
javascript logo
function regexAll (text, array) {

    for (let i in array) {
        let regex = array[i][0]
        regex = typeof regex === 'string' ? new RegExp (regex, 'g') : new RegExp (regex)
        text = text.replace (regex, array[i][1])
    }
    return text
}
10.
GoIncremental/gi-util · gi-util.js
Match rating: 64.06% · See similar code snippets
javascript logo
function test(string, regex) {
        if (typeof regex === 'string' || regex instanceof String) {
            regex=new RegExp(regex);
        }

        if (regex instanceof RegExp) {
            return regex.test(string);
        }
        else if (regex && Array.isArray(regex.and)) {
            return regex.and.every(function (item) {
                return test(string, item);
            });
        }
        else if (regex && Array.isArray(regex.or)) {
            return regex.or.some(function (item) {
                return test(string, item);
            });
        }
        else if (regex && regex.not) {
            return !test(string, regex.not);
        }
        else {
            return false;
        }
    }