Returns a string that replaces a configuration expression within a string
@param array $matches
@return string
334282
protected function replaceConfigExpression($matches) {
		$property = $matches[1];
		//check key existence
		if (!array_key_exists($property, $this->config))
			return '';
		//convert to string, if possible
		if (($str = $this->toString($this->config[$property])) === false)
			return '';
		return $str;
	}
307803
protected function calculeInverted(array $matches): string
    {
        $prefix = $matches[1];
        $negation = '' === $matches[2] ? 'Not' : '';
        $name = $matches[3];

        $inverted = sprintf('%s%s%s', $prefix, $negation, $name);

        return $inverted;
    }
716332
protected function placeHolder(array $matches)
    {
        $placeholder = '%{{' . md5(time() . count($this->holder) . mt_rand(0, 500)) . '}}%';
        $this->holder[$placeholder] = $matches['1'];

        return $placeholder;
    }
717493
public function buildMatch($match, &$params)
    {
        if (empty($match)) {
            return '';
        }

        if ($match instanceof Expression) {
            return $this->buildMatchValue($match, $params);
        }

        if (!is_array($match)) {
            return $match;
        }

        if (isset($match[0])) {
            // operator format: operator, operand 1, operand 2, ...
            $operator = strtoupper($match[0]);
            if (isset($this->matchBuilders[$operator])) {
                $method = $this->matchBuilders[$operator];
            } else {
                $method = 'buildSimpleMatch';
            }
            array_shift($match);
            return $this->$method($operator, $match, $params);
        }

        // hash format: 'column1' => 'value1', 'column2' => 'value2', ...
        return $this->buildHashMatch($match, $params);
    }
226855
protected function _pregUnQuote($pattern, $matches)
    {
      // list of escaped characters: http://www.php.net/manual/en/function.preg-quote.php
      // to properly unescape '?' which was changed to '.', I replace '\.' (real dot) with '\?', then change '.' to '?' and then '\?' to '.'.
      $search = array('\\' . self::REGEX_DELIMITER, '\\.', '\\\\', '\\+', '\\[', '\\^', '\\]', '\\$', '\\(', '\\)', '\\{', '\\}', '\\=', '\\!', '\\<', '\\>', '\\|', '\\:', '\\-', '.*', '.', '\\?');
      $replace = array(self::REGEX_DELIMITER, '\\?', '\\', '+', '[', '^', ']', '$', '(', ')', '{', '}', '=', '!', '<', '>', '|', ':', '-', '*', '?', '.');
      
      $result = substr(str_replace($search, $replace, $pattern), 2, -2);
      
      if ($matches)
      {
        foreach ($matches as $one_match)
        {
          $num_pos = strpos($result, '(\d)');
          $result = substr_replace($result, $one_match, $num_pos, 4);
        }
      }
      
      return $result;
    }
734019
protected function _replace($matches)
    {
        $required = empty($matches[2]) ? $matches[4] : $matches[2];
        $filename = $this->scanner()->find($required);
        if (!$filename) {
            throw new RuntimeException(sprintf('Could not find dependency "%s"', $required));
        }
        if (empty($this->_loaded[$filename])) {
            return $this->input($filename, file_get_contents($filename));
        }
        return '';
    }
1182698
private function normalize(array $matches) : array
    {
        $keys = $matches[1];
        $values = $matches[2];

        $return = [];

        foreach ($keys as $i => $key) {
            $key = strtolower(trim($key));

            if ($key == 'mode') {
                $value = strtolower($values[$i]);
            } else {
                $value = array_map(
                    function ($el) {
                        return trim($el, ', ');
                    },
                    explode(',', $values[$i])
                );
            }
            $return[$key] = $value;
        }

        return $return;
    }
1266453
public function compile($matches)
    {
        $overwrite = ($matches[1] == "section.overwrite") ? "true" : "false";

        if (isset($matches[6]) && !empty($matches[6])) {
            /*
            $params = $this->compiler->splitParams($matches[6], "default", function($values) {
                return $values;
            });
            
            $input = null;

            foreach($params as $key => $value)
                $input .= PHP_EOL . "if(!isset(\$$key))" . PHP_EOL . "{" . PHP_EOL . "\$$key = <<<HTML" . PHP_EOL . "$value" . PHP_EOL . "HTML;" . PHP_EOL . "}";

            $input = $this->compiler->wrap($input, "");

            return
                $this->compiler->wrap("ob_start()")
                . $input
                . $matches[7]
                . $this->compiler->wrap("\$__env->addSection(\"{$matches[3]}\", ob_get_contents(), $overwrite); ob_end_clean()");
            */
        }

        return
            $this->compiler->wrap("ob_start()")
            . $matches[7]
            . $this->compiler->wrap("\$__env->addSection(\"{$matches[3]}\", ob_get_contents(), $overwrite); ob_end_clean()");
    }
562408
private function encryptMail(array $matches): string
    {
        [, $email, $text] = $matches;

        if ($text === $email) {
            $text = '';
        }

        return
            '<span'.(!empty($this->mailCssClass) ? ' class="'.$this->mailCssClass.'"' : '').'>'.
            '<span>'.$this->getSecuredName($email).'</span>'.
                $this->mailAtText[array_rand($this->mailAtText)].
            '<span>'.$this->getSecuredName($email, true).'</span>'.
            ($text ? ' (<span>'.$text.'</span>)' : '').
            '</span>';
    }
1024422
protected function jsMatcher($matches)
    {
        $chr = $matches[0];
        if (strlen($chr) == 1) {
            return sprintf('\\x%02X', ord($chr));
        }
        $chr = $this->convertEncoding($chr, 'UTF-16BE', 'UTF-8');
        return sprintf('\\u%04s', strtoupper(bin2hex($chr)));
    }
1305884
protected function getMatchedParameters(array $matches): array
    {
        $parameters = [];
        foreach ($matches as $key => $match) {
            if (is_string($key)) {
                $parameters[$key] = $match[0];
            }
        }

        return array_replace_recursive($this->getParameters(), $parameters);
    }
265071
protected function regexUrl($matches)
    {
        $key = substr($matches[0], 1);
        if (isset($this->conditions[$key])) {
            return '(' . $this->conditions[$key] . ')';
        } else {
            return '(' . self::$conditionRegex['default'] . ')';
        }
    }
398233
private static function htmlAttrMatcher($matches) {

        $chr = $matches[0];
        $ord = ord($chr);

        //The following replaces characters undefined in HTML with the hex entity for the Unicode replacement character.
        if(($ord <= 0x1f && $chr != "\t" && $chr != "\n" && $chr != "\r") || ($ord >= 0x7f && $ord <= 0x9f)) {
            return '&#xFFFD;';
        }

        if(strlen($chr) > 1) {
            $chr = static :: convert($chr, 'UTF-8', 'UTF-32BE');
        }

        $hex = bin2hex($chr);
        $ord = hexdec($hex);

        $entities = [

	        34 => 'quot', //Quotation mark
	        38 => 'amp',  //Ampersand
	        60 => 'lt',   //Less-than sign
	        62 => 'gt',   //Greater-than sign
	    ];

        if(true === isset($entities[$ord])) {
            return '&' . $entities[$ord] . ';';
        }

        if($ord > 255) {
            return sprintf('&#x%04X;', $ord);
        }

        return sprintf('&#x%02X;', $ord);
    }
1318504
protected function literal(array $matches)
    {
        // hash from matches
        $hash = '[!' . __FUNCTION__ . '::read(' . \crc32($matches[1]) . ')!]';

        // save hash and value to literals array
        $this->literals[$hash] = $matches[1];

        // return hash value for replace
        return $hash;
    }
747301
private function applyConditions($matches)
    {
        foreach ($this->conditions as $condition) {
            $matches = $this->filter($matches, $condition);
        }

        return $matches;
    }
725249
protected function pregCallback($matches)
    {
        switch (mb_strtolower($matches[1])) {
            case 'p':
                // Replace newlines with spaces.
                $para = str_replace("\n", " ", $matches[3]);

                // Trim trailing and leading whitespace within the tag.
                $para = trim($para);

                // Add trailing newlines for this para.
                return "\n" . $para . "\n";
            case 'br':
                return "\n";
            case 'b':
            case 'strong':
                return $this->toupper($matches[3]);
            case 'th':
                return $this->toupper("\t\t" . $matches[3] . "\n");
            case 'h':
                return $this->toupper("\n\n" . $matches[3] . "\n\n");
            case 'a':
                // override the link method
                $linkOverride = null;
                if (preg_match('/_html2text_link_(\w+)/', $matches[4], $linkOverrideMatch)) {
                    $linkOverride = $linkOverrideMatch[1];
                }
                // Remove spaces in URL (#1487805)
                $url = str_replace(' ', '', $matches[3]);

                return $this->buildlinkList($url, $matches[5], $linkOverride);
        }

        return '';
    }
628753
protected function _sanitize_naughty_html($matches) {
		// encode opening brace
		$str = '&lt;' . $matches[1] . $matches[2] . $matches[3];
		
		// encode captured opening or closing brace to prevent recursive vectors
		$str .= str_replace(array('>', '<'), array('&gt;', '&lt;'), $matches[4]);
		
		return $str;
	}