设置预支的正则表达式
@param  mixed $name 名称/或者关联数组
@param  string $regexp 正则
@return self
972053
public function setRegexp($name, $regexp = null)
    {
        if (is_array($name)) {
            $this->regexps = array_merge($this->regexps, $name);
        } else {
            $this->regexps[$name] = $regexp;
        }
        return $this;
    }
591012
public void expectRegex(String name, Pattern pattern) {
        expectRegex(name, pattern, messages.get(Validation.REGEX_KEY.name(), name));
    }
1076343
public function responseHeaderMatches($name, $regex)
    {
        $actual = $this->session->getResponseHeader($name);
        $message = sprintf('The pattern "%s" was not found anywhere in the "%s" response header.', $regex, $name);

        $this->assert((bool) preg_match($regex, $actual), $message);
    }
574083
public function unsetOpt($name, $valueRegex = null)
    {
        $this->arguments[] = '--unset';
        $this->addNameAndPattern($name, $valueRegex);
        return $this;
    }
119555
private static function camelCase(string $word, string $regexp):string
    {
        $parts = array_filter(preg_split($regexp, $word));
        $keepUnchanged = array_shift($parts);
        $parts = array_map('ucfirst', $parts);
        array_unshift($parts, $keepUnchanged);

        return implode('', $parts);
    }
1352828
private static void checkRegexp(String regexp) {
        String checking = regexp.replaceAll("\\\\\\(", "X").replaceAll("\\(\\?", "X");
        int checked = checking.indexOf('(');
        if (checked > -1) {
            String msg = "Only non-capturing groups allowed:\r\n" +
                         regexp + "\r\n";
            for (int i = 0; i < checked; i++) {
                msg += " ";
            }
            msg += "^";
            throw new IllegalArgumentException(msg);
        }
    }
1281478
public Constraint regexp(String regexp, String type) {
        RegexpConstraint c = new RegexpConstraint(regexp);
        c.setType(type);
        return c;
    }
589934
public static Filter<ArchivePath> exclude(final String regexp) {
        return getFilterInstance(IMPL_CLASS_NAME_EXCLUDE_REGEXP_PATHS, new Class<?>[] { String.class },
            new Object[] { regexp });
    }
53058
public function check($regexp)
    {
        if (preg_match($regexp, $this->getRemainder(), $matches)) {
            if (strlen($matches[0]) &&
                mb_strpos($this->getRemainder(), $matches[0]) === 0) {
                return $this->setState($matches);
            }
        }
        return $this->setState();
    }
438431
function regexp($pattern, $flags = null) {
        $regexp['pattern'] = $pattern;
        if ($flags) $regexp['flags'] = $flags;
        $this->data['regexp'] = $regexp;
        return $this;
    }
323177
function cloneRegExp(regexp) {
    var result = new regexp.constructor(regexp.source, reFlags.exec(regexp));
    result.lastIndex = regexp.lastIndex;
    return result;
  }
8854
function makeFilenameRegex(name) {
  if (!_.isString(name)) {
    throw new TypeError('name parameter must be of type "String"');
  }

  const regexString = `^${name}(?:[.](.+))?.(${fileExtensions.join('|')})$`;
  return new RegExp(regexString);
}
858780
public static Filter<ArchivePath> include(String regexp) {
        return getFilterInstance(IMPL_CLASS_NAME_INCLUDE_REGEXP_PATHS, new Class<?>[] { String.class },
            new Object[] { regexp });
    }
536313
public static function regexp($val, $regexp, $default = null): bool
    {
        $options = [
            'regexp' => $regexp
        ];

        if ($default !== null) {
            $options['default'] = $default;
        }

        return (bool)\filter_var($val, \FILTER_VALIDATE_REGEXP, ['options' => $options]);
    }
895285
private function prepareRegexp($exp)
    {
        // remove surrounding '/' marks so that they don't get escaped in next step
        if ($exp{0} !== '/' || $exp{strlen($exp) - 1} !== '/') {
            $exp = '/' . $exp . '/';
        }

        // if they did not escape / chars; we do that for them
        $exp = preg_replace('/([^\\\])\/([^$])/', '$1\/$2', $exp);

        return $exp;
    }
505151
function (regexp) {
        var res = maybeCallNative(nativeMatch, regexp, this);
        if (res.done) return res.value;

        var rx = anObject(regexp);
        var S = String(this);

        if (!rx.global) return regExpExec(rx, S);

        var fullUnicode = rx.unicode;
        rx.lastIndex = 0;
        var A = [];
        var n = 0;
        var result;
        while ((result = regExpExec(rx, S)) !== null) {
          var matchStr = String(result[0]);
          A[n] = matchStr;
          if (matchStr === '') rx.lastIndex = advanceStringIndex(S, toLength(rx.lastIndex), fullUnicode);
          n++;
        }
        return n === 0 ? null : A;
      }
525828
protected function parseRegexp($regexp)
	{
		$this->captures = [['name' => null, 'expr' => null]];
		$regexpInfo = $this->getRegexpInfo($regexp);
		$this->delimiter = $regexpInfo['delimiter'];
		$this->modifiers = str_replace('D', '', $regexpInfo['modifiers']);
		foreach ($regexpInfo['tokens'] as $token)
		{
			if ($token['type'] !== 'capturingSubpatternStart')
			{
				continue;
			}
			$this->captures[] = [
				'pos'    => $token['pos'],
				'name'   => (isset($token['name'])) ? $token['name'] : null,
				'expr'   => $token['content']
			];
		}
	}