Function used to make the given pattern global.

@param  {RegExp} pattern - Regular expression to make global.
@return {RegExp}
773772
function makeGlobal(pattern) {
  var flags = 'g';

  if (pattern.multiline) flags += 'm';
  if (pattern.ignoreCase) flags += 'i';
  if (pattern.sticky) flags += 'y';
  if (pattern.unicode) flags += 'u';

  return new RegExp(pattern.source, flags);
}
876790
function match(input, patterns = []){
	if(!patterns || 0 === patterns.length)
		return false;
	
	input    = String(input);
	patterns = arrayify(patterns).filter(Boolean);
	for(const pattern of patterns)
		if((pattern === input && "string" === typeof pattern)
		|| (pattern instanceof RegExp) && pattern.test(input))
			return true;
	return false;
}
1059825
function (pattern) {
        // Escape everything except ? and *.
        pattern = pattern.replace(regexes.escapeMatcher, regexes.escapeMatchReplacement);
        pattern = pattern.replace(regexes.questionmarkMatcher, regexes.questionmarkReplacment);
        pattern = pattern.replace(regexes.starMatcher, regexes.starReplacement);
        return new RegExp(PREFIX_DELIMITER + pattern + POSTFIX_DELIMITER);
    }
889797
public static Expression regexpContains(String expression, String pattern) {
        return regexpContains(x(expression), pattern);
    }
1351871
def _prepare_pattern(self, pattern):
        
        regex, _, rest = pattern.partition('\\;')
        try:
            return re.compile(regex, re.I)
        except re.error as e:
            warnings.warn(
                "Caught '{error}' compiling regex: {regex}"
                .format(error=e, regex=regex)
            )
            # regex that never matches:
            # http://stackoverflow.com/a/1845097/413622
            return re.compile(r'(?!x)x')
248295
function pattern(toMatch) {
  var regexps = getQMarkPaths(toMatch, [])

  //reassign array to compiled regular expressions
  regexps.forEach(function(aPath, ix) {
    regexps[ix] = compile(aPath, true).regexp //'true' tells regexp compiler to math till end => '$'
  })


  if (regexps.length === 1) { //fast case
    var reg = regexps[0]
    return reg.test.bind(reg)
  } else { //test each potential path
    return function (testAgainst) {
      for (var i = 0; i < regexps.length; i++) {
        if (regexps[i].test(testAgainst)) return true
      }

      return false
    }
  }
}
176431
function isNotAPattern(pattern) {
  let set = new Minimatch(pattern).set;
  if (set.length > 1) {
    return false;
  }

  for (let j = 0; j < set[0].length; j++) {
    if (typeof set[0][j] !== 'string') {
      return false;
    }
  }

  return true;
}
627686
function(regex){
		//if it isn't global, `exec()` will not start at `lastIndex`
		if(!regex.global)
			regex.compile(regex.source, flags(regex));
		regex.lastIndex = this.position;
		var m = regex.exec(this.source);

		//all matches must start at the current position.
		if(m && m.index!=this.position){
			return null;
		}

		if(m) this.position += m[0].length;
		return m;
	}
893836
function compilePattern(pattern) {
  // pass estree syntax tree obj
  if (pattern && pattern.type) return pattern;

  if (typeof pattern !== 'string') {
    throw new Error('input pattern is neither a string nor an estree node.');
  }

  let exp = parser(pattern);

  if (exp.type !== 'Program' || !exp.body) {
    throw new Error(`Not a valid expression:  "${pattern}".`);
  }

  if (exp.body.length === 0) {
    throw new Error(`There is no statement in pattern "${pattern}".`);
  }

  if (exp.body.length > 1) {
    throw new Error(`Multiple statements is not supported "${pattern}".`);
  }

  exp = exp.body[0];
  // get the real expression underneath
  if (exp.type === 'ExpressionStatement') exp = exp.expression;
  return exp;
}
702925
public static String convertGlobToRegex(String pattern) {
    pattern = pattern.replaceAll("[\\\\\\.\\(\\)\\+\\|\\^\\$]", "\\\\$0");
    pattern = pattern.replaceAll("\\[\\\\\\^", "[^");

    pattern = Ruby.String.of(pattern).gsub("\\{[^\\}]+\\}", m -> {
      m = m.replaceAll(",", "|");
      m = "(" + m.substring(1, m.lastIndexOf('}')) + ")";
      return m;
    }).toS();
    pattern = pattern.replaceAll("\\?", ".{1}");
    pattern = pattern.replaceAll("\\*\\*/", "(.+/)?");
    pattern = pattern.replaceAll("\\*", "[^/]*");
    return pattern;
  }
1135711
protected Pattern compilePattern(Element regex, int flags) {

		Pattern p = null;
		try {
			String re = ((StringProperty) regex).getValue();
			p = Pattern.compile(re, flags);
		} catch (PatternSyntaxException pse) {
			throw EvaluationException.create(sourceRange, MSG_INVALID_REGEXP,
					pse.getLocalizedMessage());
		}

		return p;
	}
260030
function createPatternVariations(pattern) {
    var lastCharIdx = pattern.length - 1,
        patternVariations = [pattern, '!' + pattern];

    if (pattern[lastCharIdx] === '/') {
        var unslashed = pattern.substring(0, lastCharIdx);

        patternVariations.push(unslashed);
        patternVariations.push('!' + unslashed);
    }

    return patternVariations;
}
78169
function brackets(pattern, options) {
  const res = brackets.create(pattern, options);
  return res.output;
}
711347
private static String patternToString(@Nullable final Pattern pattern) {
		return pattern != null ? pattern.pattern() + " (flags: " + pattern.flags() + ")" : NO_PATTERN_PLACEHOLDER;
	}
872920
function rgx(regexp) {
        return new Pattern(regexp + '', function (str, pos) {
            var m = regexp.exec(str.slice(pos));
            if (m && m.index === 0) // regex must match at the beginning, so index must be 0
                return { res: m[0], end: pos + m[0].length };
        });
    }
1325644
function (pattern, options) {
    var self = this;
    function find() {
      var isMatch = lazy.mm.matcher(pattern, options);
      for (var key in self) {
        var val = self[key];
        if (typeof val === 'object' && isMatch(key)) {
          return val;
        }
      }
    }
    var res = this.fragmentCache(pattern, find);
    res.__proto__ = this;
    return res;
  }
1088346
private static function toUnicodeRegex (& $pattern)
  {
    $d = $pattern[0];
    list ($exp, $flags) = explode ($d, substr ($pattern, 1), 2);
    $flags   = str_replace ('a', '', $flags, $isGlobal);
    $flags   = str_replace ('u', '', $flags) . 'u';
    $pattern = "$d$exp$d$flags";
    return $isGlobal;
  }