根据匹配分组获取需要匹配的正则表达式字符串
@param $pattern
@return $matcher string
191643
public function getPatternRegexp($pattern)
    {
        $matcher = $pattern;
        $matcher = trim($matcher, '/');
        $cases = $this->caseSensitive ? '' : 'i';

        if (!$matcher) {
            $matcher = '|^/$|';
        } elseif ($matcher === '*') {
            $matcher = '|^.*$|' . $cases;
        } elseif ($matcher[0] == '|') {
            //正则表达式
            $matcher = $matcher . $cases;
        } else {
            //替换 *为匹配除了 /分组之外的所有内容

            /**
             * 防止路由中出现正则表达式特殊字符 例如 - : <> 这样的特殊字符
             */
            $matcher = preg_quote($matcher,'|');
            $matcher = str_replace(['\*','\:','\[','\]','\.'],['*',':','[',']','.'],$matcher);

            $matcher = str_replace(['*', '?'], ['([^\/]*)', '([^\/]?)'], $matcher);
            $slices = $this->getSlice($matcher);
            foreach ($slices as list($slice, $reg)) {
                if (strpos($slice, '[') !== false) {
                    $matcher = str_replace($slice, $reg, $matcher);
                } else {
                    $matcher = str_replace(':' . $slice, $reg, $matcher);
                }
            }
            $matcher = '|^' . $matcher . '$|' . $cases;
        }
        return $matcher;
    }
1058530
public function escapeLikePattern(string $pattern): string {
		$esc = $this->getLikeEscapeCharacter();
		return str_replace(array($esc, QueryComparator::LIKE_WILDCARD_MANY_CHARS,
				QueryComparator::LIKE_WILDCARD_ONE_CHAR),
				array($esc . $esc,  $esc . QueryComparator::LIKE_WILDCARD_MANY_CHARS, $esc .
						QueryComparator::LIKE_WILDCARD_ONE_CHAR), $pattern);
	}
396337
protected function findFilesInCacheDir($pattern)
    {
        $finder = new Finder();
        
        return $finder
            ->name($pattern)
            ->in($this->getCacheDir())
        ;
    }
469671
public function parse($pattern)
    {
        //reset must be extracted
        $this->mustBeExtracted = array();
        //filter to lower and remove accentued
        $filteredPattern = mb_strtolower($this->remove_accents($pattern));

        $terms = $this->extractTerms($filteredPattern);
        $terms['_domain'] = $this->extractDomain($filteredPattern);
        $terms['_default'] = $this->extractDefault($filteredPattern);

        return $terms;
    }
850574
public function matching ($pattern, &$matches = [], $flags = 0, $offset = 0, $start = 0, $end = null) {
		if (is_null($end)) {
			$end = $this->_length;
		}
		return static::Match($pattern, static::Substring($this->_string, $start, $end), $matches, $flags, $offset);
	}
414735
private function getMatchStringParameterIndices($matchString, $pattern)
    {
        $indices = [];

        foreach ($pattern as $part) {
            if (!$this->isTokenPatternPart($part)) {
                $offset = 0;

                foreach ($indices as $currentIndex) {
                    $prefix = $currentIndex['prefix'];

                    if ($prefix == $part || substr_count($prefix, $part) || substr_count($part, $prefix)) {
                        $offset = $currentIndex['index'];
                    }
                }

                $indices[] = [
                    'prefix' => $part,
                    'index' => strpos($matchString, $part, $offset) + strlen($part)
                ];
            }
        }

        return $indices;
    }
1069467
private function preparePattern($pattern)
    {
        $delimiterPattern = '/\\\\*' . self::DELIMITER . '/';

        // The following block escapes usages of the delimiter in the pattern if it's not already escaped.
        if (preg_match_all($delimiterPattern, $pattern, $matches, PREG_OFFSET_CAPTURE)) {
            $diffOffset = 0;

            foreach ($matches[0] as $match) {
                $str = $match[0];
                $offset = $match[1] + $diffOffset;

                $escStr = (strlen($str) % 2) ? '\\' . $str : $str; // This will increase an even number of backslashes, before a forward slash, to an odd number.  I.e. '\\/' becomes '\\\/'.

                $diffOffset += strlen($escStr) - strlen($str);

                $pattern = substr_replace($pattern, $escStr, $offset, strlen($str));
            }
        }

        return self::DELIMITER . $pattern . self::DELIMITER . $this->getModifiers();
    }
636542
protected function normalizeRegexPattern($pattern)
    {
        if (false !== @preg_match($pattern, null)) {
            return $pattern;
        }

        $boundedPattern = '~\b' . str_replace('~', '\~', $pattern) . '\b~';

        if (false !== @preg_match($boundedPattern, null)) {
            return $boundedPattern;
        }

        return '~\b' . preg_quote($pattern, '~') . '\b~';
    }
802991
protected function getSegments($pattern)
	{
		$segments = array();
		$parts = \explode("/", ltrim($pattern, "/"));

		foreach ($parts as $segment)
		{
			if (\strpos($segment, ":") !== false)
			{
				$segments[] = $this->parseSegment($segment);
			}
		}

		return $segments;
	}
223467
private static function _normalize($pattern)
    {
        return self::$_delimiter . trim($pattern, self::$_delimiter)
            . self::$_delimiter;
    }
82001
public function matchPattern(string $pattern) : Element
    {
        $this->attributes['pattern'] = $pattern;
        return $this->addTest('pattern', function ($value) use ($pattern) {
            return preg_match("@^$pattern$@", trim($value));
        });
    }
1170525
public function toWeekDays($pattern)
    {
        $weekDays = $this->getWeekDays();

        $formatedDays = [];

        foreach (str_split($pattern) as $key => $day) {
            if (array_key_exists($day, $weekDays) && intval($day) === 1) {
                $formatedDays[] = $weekDays[$key];
            }
        }

        return join(', ', $formatedDays);
    }
924856
public function match($pattern)
    {
        if (!is_string($pattern)) {
            throw new InvalidStringException('pattern', $pattern);
        } elseif (empty($pattern)) {
            throw new InvalidNotEmptyException('pattern');
        }

        if (!is_string($this->value)) {
            throw new InvalidStringException($this->name, $this->value);
        }

        // God please sorry for this @
        $checkResult = @preg_match($pattern, $this->value);

        if ((preg_last_error() !== PREG_NO_ERROR) || ($checkResult === false)) {
            throw new InvalidRegExpPatternException('pattern', $pattern);
        }

        if ($checkResult === 0) {
            throw new StringNotMatchRegExpException($this->name, $this->value, $pattern);
        }

        return $this;
    }
193512
protected function parsePlaceholders($pattern)
    {
        $params = [];
        $parser = $this->parser;

        preg_match_all("~" . $parser::DYNAMIC_REGEX . "~x", $pattern, $matches, PREG_SET_ORDER);

        foreach ((array) $matches as $key => $match) {
            $pattern = str_replace($match[0], isset($match[2]) ? "({$match[2]})" : "([^/]+)", $pattern);
            $params[$key] = $match[1];
        }

        return [$pattern, $params];
    }
1071178
public function matches($name, $pattern, &$matches = []) {
		return preg_match($pattern, $this->get($name), $matches);
	}
7882
public static function safePattern($pattern)
    {
        $delimiter = \mb_substr($pattern, 0, 1);
        $options = \mb_substr(
            \mb_strrchr($pattern, $delimiter, false),
            \mb_strlen($delimiter)
        );

        if (false === \strpos($options, 'u')) {
            $pattern .= 'u';
        }

        return $pattern;
    }
144779
private function prefixPattern($pattern)
    {
        $d = '/';

        if (!$this->hasGroups()) {
            return $d.trim($pattern, $d);
        }

        $prefix = $this->getCurrentGroup()->getPrefix();

        return rtrim(($d === $prefix ? $prefix : (rtrim($prefix, $d).$d)) . trim($pattern, $d), $d);
    }