@param string $htmlErrorString
@param string[] $pattern

@return bool|null
965909
private function simpleMatchRejection($htmlErrorString, $pattern)
    {
        foreach ($pattern as $part) {
            if (!$this->isTokenPatternPart($part)) {
                if (substr_count($htmlErrorString, $part) === 0) {
                    return false;
                }
            }
        }

        return null;
    }
52986
protected function getErrorLevelForAdditionalHtml($html)
	{
		if (preg_match('#^<(i|b|ul|ol|li|h3)( style="[a-zA-Z0-9_\:\ \;\-]+")?>$#', $html))
		{
			return Output::ERROR;
		}

		if (in_array($html, array(
			'<em>',
			'<strong>',
			'<samp>',
			'<u>',
			'<br />',
			'<br>',
			'<hr>'
		)))
		{
			return Output::NOTICE;
		}

		if (preg_match('#^<a href="([a-zA-Z0-9_\:\&\/\?\.\-\#\@]+)">$#', $html) ||
			preg_match('#^<a href="([a-zA-Z0-9_\:\&\/\?\.\-\#]+)" rel="external">$#', $html))
		{
			return Output::ERROR;
		}

		return Output::FATAL;
	}
447516
public function pattern($pattern = null)
        {
            if ($pattern === null) return $this->rulePattern;

            $this->rulePattern = $pattern;

            return $this;
        }
1088835
public function notMatch($pattern) {
        if (!$this->_isValid) {
            return $this;
        }
        if (preg_match($pattern, $this->_unsafeVar)) {
            $this->_isValid = false;
        }
        return $this;
    }
371390
public function matchesPattern($event, $pattern)
    {
        if ($pattern === '*') {
            return true;
        }

        if ($event == $pattern) {
            return true;
        }

        return fnmatch($pattern, $event);
    }
391641
private function getQuotedParameterNormalisedError($htmlErrorString)
    {
        $parameterMatches = [];
        $matchCount = preg_match_all('/"([^"]?)+"/', $htmlErrorString, $parameterMatches);

        if ($matchCount === 0) {
            return null;
        }

        $normalisedError = new NormalisedError();
        $normalisedErrorString = $htmlErrorString;

        foreach ($parameterMatches[0] as $parameterIndex => $parameterMatch) {
            $normalisedErrorString = preg_replace(
                '/' . PregQuoter::quote($parameterMatch) . '/',
                '"%'.$parameterIndex.'"',
                $normalisedErrorString,
                1
            );
            $normalisedError->addParameter(trim($parameterMatch, '"'));
        }

        $normalisedError->setNormalForm($normalisedErrorString);

        return $normalisedError;
    }
901083
public function isPatternMatches($pattern, $routePattern = false)
    {
        $uri = $this->removeIndexDotPhpAndTrillingSlash($this->getCurrentUri());
        $hasPattern = $this->hasNamedPattern($pattern);
        $pattern = ($hasPattern == false) ? $pattern : $hasPattern;
        if (preg_match_all(
            '#^' . $pattern . '$#',
            $uri,
            $matches,
            PREG_SET_ORDER
        )) {
            return $matches;
        }
    }
1024952
public function render_html_error_email( $exception, CssToInlineStyles $inliner = null ) {
		$plates = _soter_instance( 'plates' );
		$html = $plates->render( 'emails/html/error.php', [
			'message' => $exception->getMessage(),
		] );
		$css = $plates->render( 'emails/style.css' );
		$inliner = $inliner ?: new CssToInlineStyles();

		return $inliner->convert( $html, $css );
	}
1319885
public function assertResponseStatusLineMatches($pattern) {
        $this->requireResponse();

        try {
            $actualStatusLine = sprintf(
                '%d %s',
                $this->response->getStatusCode(),
                $this->response->getReasonPhrase()
            );

            Assertion::regex(
                $actualStatusLine,
                $pattern,
                sprintf(
                    'Expected the response status line to match the regular expression "%s", got "%s".',
                    $pattern,
                    $actualStatusLine
                ));
        } catch (AssertionFailure $e) {
            throw new AssertionFailedException($e->getMessage());
        }
    }
1355082
static public function regex($value, $pattern, $message = null, $propertyPath = null)
        {
            static::string($value, $message);

            if ( ! preg_match($pattern, $value)) {
                $message = $message ?: sprintf(
                    'Value "%s" does not match expression.',
                    static::stringify($value)
                );

                throw static::createException($value, $message, static::INVALID_REGEX , $propertyPath, array('pattern' => $pattern));
            }
        }
337440
public function render($htmlview = null, $textview = null) {

		if(null !== $htmlview && false === is_string($htmlview)) {
			return trigger_error(sprintf('Argument 1 passed to %s() must be of the type string, "%s" given', __METHOD__, gettype($htmlview)), E_USER_ERROR);
		}

		if(null !== $textview && false === is_string($textview)) {
			return trigger_error(sprintf('Argument 2 passed to %s() must be of the type string, "%s" given', __METHOD__, gettype($textview)), E_USER_ERROR);
		}

		$this -> viewmodels = ['html' => $htmlview, 'text' => $textview];

		return $this;
	}
1072463
public function format($pattern, $params, $language)
    {
        $this->_errorCode = 0;
        $this->_errorMessage = '';

        if ($params === []) {
            return $pattern;
        }

        if (! class_exists('MessageFormatter', false)) {
            return $this->fallbackFormat($pattern, $params, $language);
        }

        // replace named arguments (https://github.com/yiisoft/yii2/issues/9678)
        $pattern = $this->replaceNamedArguments($pattern, $params, $newParams);
        $params = $newParams;

        $formatter = new \MessageFormatter($language, $pattern);
        if ($formatter === null) {
            $this->_errorCode = intl_get_error_code();
            $this->_errorMessage = 'Message pattern is invalid: ' . intl_get_error_message();

            return false;
        }
        $result = $formatter->format($params);
        if ($result === false) {
            $this->_errorCode = $formatter->getErrorCode();
            $this->_errorMessage = $formatter->getErrorMessage();

            return false;
        } else {
            return $result;
        }
    }
456960
public function assertResponseReasonPhraseMatches($pattern) {
        $this->requireResponse();

        try {
            Assertion::regex(
                $actual = $this->response->getReasonPhrase(),
                $pattern,
                sprintf(
                    'Expected the response reason phrase to match the regular expression "%s", got "%s".',
                    $pattern,
                    $actual
                ));
        } catch (AssertionFailure $e) {
            throw new AssertionFailedException($e->getMessage());
        }
    }
50250
public function assertHtmlContentMatches($selectorString, $expected)
    {
        $this->assertEqual(trim($this->getHtmlContent($selectorString)), $expected);
    }
1081855
private static function PrepareRegexPattern( $pattern, $flagString )
	{

		// Check the pattern does not include a back-reference in a character class
		$result = preg_match( "/\[.*?\\\\\d+.*?\]/", $pattern );
		if ( $result )
		{
			throw XPath2Exception::withErrorCodeAndParam( "FORX0002", Resources::InvalidRegularExpr, "$pattern/$flagString" );
		}

		// If one of the flags is x then need to remove whitespace not in character classes
		// PCRE will not remove escaped spaces when the x flag is used but XPath expects them to be removed
		if ( strpos( $flagString, "x" ) !== false )
		{
			$results = preg_match_all( "/((?<expr>[^[]*)(?<chars>\[.*?\])?)/", $pattern, $matches );
			for ( $i = 0; $i < $results; $i++ )
			{
				$match = $matches['expr'][ $i ];
				if ( empty( $match) ) continue;
				$result = preg_replace( "/((?![\r\n])\s)+/", "", $match );
				if ( $match == $result ) continue;
				$pattern = str_replace( $match, $result, $pattern );
			}
		}

		// If there is a back-reference need to add an empty comment to separate the
		// back-reference number from any following digit(s) and repeat for all back-references
		// $groups = substr_count( $pattern, "(" );
		// This pattern counts the parentheses that are not escaped by just one backslash (two is OK)
		$groups = preg_match_all( '/\\\\\\\\\(|\((?<!\\\\\()/', $pattern );
		if ( $groups )
		{
			// Get a list of all the back reference numbers
			$result = preg_match_all( "/\\\\(\d(\d?))*/", $pattern, $matches );
			if ( $result )
			{
				// $result2 = preg_match_all( "/\((([^()]+)|(?R))*\)/", $pattern, $parens );

				// Grab the valid values
				$values = array();
				foreach ( array_filter( $matches[1] ) as $key => $match )
				{
					$potentialValues = array();
					while ( strlen( $match ) > 0 )
					{
						$potentialValues[] = $match;
						$match = substr( $match, 0, strlen( $match ) - 1 );
					}

					sort( $potentialValues );
					$error = false;
					while ( count( $potentialValues ) )
					{
						$value = array_pop( $potentialValues );

						// Find the match(es) in the string and count the number of opening parentheses until that point
						$pos = strpos( $pattern, $value );

						// $matchgroupsOpen = substr_count( $pattern, "(", 0, $pos );
						// This horrible list of backslashes occurs because the regex escape char is \ and the same for PHP.
						// So every real backslash has to be quadrupled. Here's what the regex will look like outside PHP
						// 	/\\\\\(|\((?<!\\\()/
						$matchgroupsOpen = preg_match_all( '/\\\\\\\\\(|\((?<!\\\\\()/', substr( $pattern, 0, $pos ) );

						// If there are no groups throw an exception
						$error = ! $matchgroupsOpen || $matchgroupsOpen < $value;

						if ( ! $error )
						{
							// $matchgroupsClosed = substr_count( $pattern, ")", 0, $pos );
							$matchgroupsClosed = preg_match_all( '/\\\\\\\\\)|\)(?<!\\\\\))/', substr( $pattern, 0, $pos ) );

							// If reference is in a capture group its an error
							$error = ! $matchgroupsClosed || $matchgroupsClosed != $matchgroupsOpen || $matchgroupsClosed < $value;

							if ( $error ) continue;
							// This is the longest number
							$values[] = $value;
							break;
						}
					}

					if ( $error )
					{
						throw XPath2Exception::withErrorCode( "FORX0002", Resources::FORX0002 );
					}
				}

				// Make sure the back-reference numbers are valid given the list of capture groups available
				$validValues = array_intersect( $values, range( 1, $groups ) );

				// Sort them in descending order so the longest number is handled first.
				// This way \1 and \11 are handled correctly.
				// BMS Not sure this is necessary.
				rsort( $validValues );
				foreach ( $validValues as $value )
				{
					// Replace the number but only if the number is not already followed by an empty comment
					$pattern = preg_replace( "/\\\\($value)(?!\d?\(\?\#\))/", "\\\\$1(?#)", $pattern );
				}
			}
		}

		// Check to see if there are any character classes that specify character subtraction
		// If so, convert to a negative lookahead
		$results = preg_match_all( "/\[(?<chars>((.*)?(.-.))+)-(?<sub>\[(.*|.*?(.-.))+\])\]/", $pattern, $matches );
		if ( $results )
		{
			for ( $i = 0; $i < $results; $i++ )
			{
				$chars = $matches['chars'][ $i ];
				$sub = $matches['sub'][ $i ];
				$x = "(?!$sub)[$chars]";

				$pattern = str_replace( $matches[ $i ], $x, $pattern );
			}
		}

		// Replace common unicode character classes
		$pattern = str_replace( "{IsBasic", "{", $pattern );

		return $pattern;
	}
375024
protected function assertPattern($pattern)
    {
        if (strlen($pattern) == 0) return null;

        $pattern = '/^'. str_replace('/', '\\/', $pattern). '$/';
        if (@preg_match($pattern, null) === false) {
            throw new DefinitionException("invalid regular expression pattern");
        }

        return $pattern;
    }
599080
public function when($pattern, $name, $methods = null)
	{
		if ( ! is_null($methods)) $methods = array_map('strtoupper', (array) $methods);

		$this->patternFilters[$pattern][] = compact('name', 'methods');
	}