@param string[] $pattern

@return string
351163
private function getRegexPatternFromHtmlErrorPattern($pattern)
    {
        $regexPattern = '';

        foreach ($pattern as $part) {
            if ($this->isTokenPatternPart($part)) {
                $regexPattern .= '.*';
            } else {
                $regexPattern .= PregQuoter::quote($part);
            }
        }

        return '/' . $regexPattern . '/is';
    }
1345872
private function getOptionByRegExpr(string $pattern): array
    {
        $purgedArgs = $this->getRawArgs(true);
        return preg_grep("/" . $pattern . "/", $purgedArgs);
    }
901256
public function setPattern($name, $pattern)
    {
        if (is_array($pattern)) {
            return $this->provideHelper($this->patternName($name), $pattern);
        }

        $this->registerHelper('patterns.'.$name, $pattern);

        return $this->provideHelper($this->patternName($name), [
            'pattern',
            'patterns.'.$name,
            function ($proceed, $pattern) {
                return function () use ($proceed, $pattern) {
                    $args = func_get_args();
                    array_unshift($args, $pattern);

                    return call_user_func_array($proceed, $args);
                };
            },
        ]);
    }
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));
        });
    }
317910
public function getNonVariables($pattern) {
        $exp = explode('/',$pattern);
        $retorno = [];
        foreach($exp as $i => $v) {
            if(!preg_match('/^[\:]/i', $v)) {
                $retorno[$i] = $v;
            }
        }

        return $retorno;
    }
563863
private function toRegex(string $pattern): string
    {
        while (\preg_match(self::OPTIONAL_PLACEHOLDER_REGEX, $pattern)) {
            $pattern = \preg_replace(self::OPTIONAL_PLACEHOLDER_REGEX, '($1)?', $pattern);
        }

        $pattern = \preg_replace_callback(self::REQUIRED_PLACEHOLDER_REGEX, function (array $match = []) {
            $match = \array_pop($match);
            $pos = \mb_strpos($match, self::REGEX_PREFIX);
            if (false !== $pos) {
                $parameterName = \mb_substr($match, 0, $pos);
                $parameterRegex = \mb_substr($match, $pos + 2);

                return "(?<$parameterName>$parameterRegex)";
            }

            return "(?<$match>[^/]+)";
        }, $pattern);

        return $pattern;
    }
956394
protected static function extract($pattern)
    {
        if (str_contains($pattern, '|')) {
            $segements = explode('|', $pattern);

            $events[$segements[0]] = explode('.', $segements[1]);
        } else {
            $segements = explode('.', $pattern);

            $events[$segements[0]] = $segements[1];
        }

        return $events;
    }
1110368
protected function get_sequence( $pattern ) {
		$characters = Strings::mb_str_split( str_replace( '.', '_', $pattern ) );
		$result     = [];

		foreach ( $characters as $index => $chr ) {
			if ( ctype_digit( $chr ) ) {
				$result[] = $chr;
			} else {
				// Append '0' if this is the first character or the previous character was not a number.
				if ( ! isset( $characters[ $index - 1 ] ) || ! ctype_digit( $characters[ $index - 1 ] ) ) {
					$result[] = '0';
				}

				// Append '0' if this is the last character.
				if ( ! isset( $characters[ $index + 1 ] ) ) {
					$result[] = '0';
				}
			}
		}

		// Do some error checking.
		$count     = count( $result );
		$count_seg = mb_strlen( $this->get_segment( $pattern ) );
		$sequence  = implode( '', $result );

		if ( $count !== $count_seg + 1 ) {
			throw new \RangeException( "Invalid segment length $count for pattern $pattern (result sequence $sequence)." );
		}

		return $sequence;
	}
49807
public function backtraceFocus($pattern = null)
    {
        if ($pattern === null) {
            return $this->_backtraceFocus;
        }
        $patterns = is_array($pattern) ? $pattern : [$pattern];
        foreach ($patterns as $key => $value) {
            $patterns[$key] = preg_quote($value, '~');
        }
        $pattern = join('|', $patterns);
        return $this->_backtraceFocus = strtr($pattern, ['\*' => '.*', '\?' => '.']);
    }
68489
protected static function splite($pattern)
    {
        if (is_array($pattern)) {
            $events = [];

            foreach ($pattern as $value) {
                $events = array_collapse([$events, self::extract($value)]);
            }

            return $events;
        } elseif (is_string($pattern)) {
            return self::extract($pattern);
        }
    }
101384
private function getNormalForm($pattern)
    {
        $normalForm = '';
        $parameterIndex = 0;

        foreach ($pattern as $part) {
            if ($this->isTokenPatternPart($part)) {
                $normalForm .= '%' . $parameterIndex;
                $parameterIndex++;
            } else {
                $normalForm .= $part;
            }
        }

        return $normalForm;
    }
728825
public function pregGet( string$pattern, /*int|string*/$match=0 ):string
	{
		preg_match($pattern,ltrim($this->content,"\t"),$matches);
		return $matches[$match]??'';
	}
548089
public static function getRoute($pattern) {
        $route = null;
        if (isset(self::$routes[$pattern])) {
            $route = self::$routes[$pattern];
        }
        return $route;
    }
809979
protected function getNestedPrefix($pattern)
    {
        $segments = explode("/", $pattern);
        $pattern = "";

        foreach ($segments as $index => $segment) {
            if (strpos($segment, "{") === 0) {
                   $pattern .= "/{" . $segments[$index - 1] . "_" . ltrim($segment, "{");
            } else $pattern .= $segment;
        }

        return $pattern;
    }
975847
protected function matchesPattern($pattern)
	{
		trigger_error('Function ' . __METHOD__ . ' not implemented yet');

		$regexEncoding = $this->regexEncoding();
		$this->regexEncoding($this->encoding);

		$match = \mb_ereg_match($pattern, $this->str);
		$this->regexEncoding($regexEncoding);

		return $match;
	}
943207
public function transformPatternToRegex($pattern)
    {
        if (!isset($this->patternToRegexpCache[$pattern])) {
            $this->patternToRegexpCache[$pattern] = $this->transformPatternToRegexWithSupportedPolicy($pattern);
        }

        return $this->patternToRegexpCache[$pattern];
    }
418946
private function getNodeTypeAndPattern($pattern)
    {
        $node_type = 'text';

        // If user set payload, default, welcome message.
        foreach (['payload', 'default', 'attachment'] as $type) {
            if (strpos($pattern, $type . ':') !== false) {
                $node_type = $type;
                $pattern = str_replace($node_type . ':', '', $pattern);
            }
        }

        if (!empty($pattern) && $pattern[0] == '@') {
            $node_type = 'intended';
            $pattern = str_replace('@', '', $pattern);
        }

        return [$node_type, $pattern];
    }