Create a regular expression from the given `pattern` string.

@param {String|RegExp} `pattern` Pattern can be a string or regular expression.
@param {Object} `options`
@return {RegExp}
@api public
552575
function makeRe(pattern, options) {
  if (pattern instanceof RegExp) {
    return pattern;
  }

  if (typeof pattern !== 'string') {
    throw new TypeError('expected a string');
  }

  if (pattern.length > MAX_LENGTH) {
    throw new Error('expected pattern to be less than ' + MAX_LENGTH + ' characters');
  }

  var key = pattern;
  // do this before shallow cloning options, it's a lot faster
  if (!options || (options && options.cache !== false)) {
    key = createKey(pattern, options);

    if (cache.hasOwnProperty(key)) {
      return cache[key];
    }
  }

  var opts = extend({}, options);
  if (opts.contains === true) {
    if (opts.negate === true) {
      opts.strictNegate = false;
    } else {
      opts.strict = false;
    }
  }

  if (opts.strict === false) {
    opts.strictOpen = false;
    opts.strictClose = false;
  }

  var open = opts.strictOpen !== false ? '^' : '';
  var close = opts.strictClose !== false ? '$' : '';
  var flags = opts.flags || '';
  var regex;

  if (opts.nocase === true && !/i/.test(flags)) {
    flags += 'i';
  }

  try {
    if (opts.negate || typeof opts.strictNegate === 'boolean') {
      pattern = not.create(pattern, opts);
    }

    var str = open + '(?:' + pattern + ')' + close;
    regex = new RegExp(str, flags);

    if (opts.safe === true && safe(regex) === false) {
      throw new Error('potentially unsafe regular expression: ' + regex.source);
    }

  } catch (err) {
    if (opts.strictErrors === true || opts.safe === true) {
      err.key = key;
      err.pattern = pattern;
      err.originalOptions = options;
      err.createdOptions = opts;
      throw err;
    }

    try {
      regex = new RegExp('^' + pattern.replace(/(\W)/g, '\\$1') + '$');
    } catch (err) {
      regex = /.^/; //<= match nothing
    }
  }

  if (opts.cache !== false) {
    memoize(regex, key, pattern, opts);
  }
  return regex;
}
1089940
public String createPatternString(String pattern, int length) {
        if (pattern == null) {
            return null;
        }

        int totalLength = pattern.length() * length;
        StringBuffer sb = new StringBuffer(totalLength);
        for (int i = 0; i < length; i++) {
            sb.append(pattern);
        }
        return sb.toString();
    }
79538
public HString findPattern(@NonNull Pattern regex) {
      Matcher m = matcher(regex);
      if (m.find()) {
         return union(substring(m.start(), m.end()).tokens());
      }
      return Fragments.empty(document());
   }
1294768
public static Expression regexpContains(Expression expression, String pattern) {
        return x("REGEXP_CONTAINS(" + expression.toString() + ", \"" + pattern + "\")");
    }
326325
public static Query regex(String field,
                              String pattern,
                              int options) {
        return regex(field, pattern, is(options, CASE_INSENSITIVE), is(options, EXTENDED), is(options, MULTILINE), is(options, DOTALL));
    }
77651
function buildPattern(patternObj, options) {
  const patternFile = { path: patternObj.path };
  return Object.assign(patternObj, {
    name:
      (patternObj.data && patternObj.data.name) ||
      titleCase(resourceKey(patternFile))
  });
}
1283304
public static Expression regexpPosition(String expression, String pattern) {
        return regexpPosition(x(expression), pattern);
    }
431754
function pattern (val, pat) {
  if (typeof pat !== 'string') { return false }

  var match = pat.match(new RegExp('^/(.*?)/([gimy]*)$'));
  if (!match) { return false }

  return new RegExp(match[1], match[2]).test(val)
}
857939
public static TokenRegex compile(String pattern) throws ParseException {
      ExpressionIterator p = QueryToPredicate.PARSER.parse(pattern);
      Expression exp;
      TransitionFunction top = null;
      while ((exp = p.next()) != null) {
         if (top == null) {
            top = consumerize(exp);
         } else {
            top = new TransitionFunction.Sequence(top, consumerize(exp));
         }
      }
      return new TokenRegex(top);
   }
171584
public FulltextMatch addPattern(
                    final String pattern
                    )
    {
        if (pattern == null  ||  pattern.length() == 0) {
            throw new IllegalArgumentException( "no pattern specified" );
        }

        _patterns.add( pattern );

        return this;
    }
168805
function(string){
				var pattern = /(^|\W)(\w)(\w*)/g,
					result = [],
					match;
				
				while (pattern.exec(string)) {
					result.push(RegExp.$1 + RegExp.$2.toUpperCase() + RegExp.$3);
				}
				
				return result.join('');
			}
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
    }
  }
}
660392
function parse (pattern, comment) {
  const match = pattern.exec(comment)
  if (match == null) {
    return null
  }

  const type = match[1]
  const rules = (match[2] || '')
    .split(',')
    .map(s => s.trim())
    .filter(Boolean)

  return { type, rules }
}
10555
public static Token parse(final String pattern) {
		List<Token> tokens = new ArrayList<Token>();

		int start = 0;
		int count = 0;

		for (int i = 0; i < pattern.length(); ++i) {
			char character = pattern.charAt(i);

			if (character == '{') {
				if (count == 0) {
					if (start < i) {
						tokens.add(new PlainTextToken(pattern.substring(start, i)));
					}
					start = i;
				}
				count += 1;
			} else if (character == '}') {
				if (count == 0) {
					InternalLogger.log(Level.ERROR, "Opening curly bracket is missing: '" + pattern + "'");
				} else {
					count -= 1;
					if (count == 0) {
						tokens.add(parse(pattern.substring(start + 1, i)));
						start = i + 1;
					}
				}
			}
		}

		if (count > 0) {
			InternalLogger.log(Level.ERROR, "Closing curly bracket is missing: '" + pattern + "'");
		}

		int splitIndex = pattern.indexOf('|', start);
		if (splitIndex == -1) {
			tokens.add(createPlainToken(pattern.substring(start)));
			return tokens.size() == 1 ? tokens.get(0) : new BundleToken(tokens);
		} else {
			String token = pattern.substring(start, splitIndex).trim();
			tokens.add(createPlainToken(token));
			String[] styleOptions = SPLIT_PATTERN.split(pattern.substring(splitIndex + 1));
			return styleToken(tokens.size() == 1 ? tokens.get(0) : new BundleToken(tokens), styleOptions);
		}
	}
825534
function matchArray(value, pattern, options) {
  if (!(value instanceof Array)) {
    return false;
  }
  if (!options.matchPartialArrays && pattern.length !== value.length) {
    return false;
  }
  if (pattern.length > value.length) {
    return false;
  }
  if (options.matchOutOfOrderArrays) {
    return pattern.every(
      (nestedMatch) => value.some(
        (nestedValue) => matchr(nestedValue, nestedMatch, options)
      )
    );
  }
  let valueIndex = 0;
  for (const nestedMatcher of pattern) {
    while (valueIndex < value.length && !matchr(value[valueIndex], nestedMatcher, options)) {
      valueIndex++;
    }
    if (valueIndex === value.length) {
      return false;
    }
  }
  return true;
}
580259
function cloneRegexp(re) {
  const pattern = re.source;

  let flags = '';

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

  return new RegExp(pattern, 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;
}