Converts the token of the matched range.

@param int         $i
@param string      $match
@param array       $matches
@param null|string $special
@param null|string $replace
430191
protected function matchRangeToken($i, $match, array &$matches, &$special, &$replace)
    {
        if (' - ' === $match) {
            $matches[$i - 1] = '>='.str_replace(array('*', 'x', 'X'), '0', $matches[$i - 1]);

            if (false !== strpos($matches[$i + 1], '.') && false === strpos($matches[$i + 1], '*')
                    && false === strpos($matches[$i + 1], 'x') && false === strpos($matches[$i + 1], 'X')) {
                $matches[$i] = ',<=';
            } else {
                $matches[$i] = ',<';
                $special = ',<~';
            }
        } else {
            $this->matchRangeTokenStep2($i, $match, $matches, $special, $replace);
        }
    }
183416
private static function numericEntitiesSingleByte($matches)
    {
        $buffer = str_split($matches[0]);
        foreach ($buffer as &$char) {
            $char = sprintf('&#%d;', ord($char));
        }

        return implode('', $buffer);
    }
616025
protected function _replaceParamsCallback($matches)
    {
        $key   = substr($matches[0], 1);
        $value = $this->_parameters[$key];

        if(!$value instanceof KDatabaseQuerySelect) {
            $value = is_object($value) ? (string) $value : $value;
            $replacement = $this->getAdapter()->quoteValue($value);
        }
        else $replacement = '('.$value.')';

        return is_array($value) ? '('.$replacement.')' : $replacement;
    }
771526
protected function matchRangeTokenStep5($i, $match, array &$matches, &$special, &$replace)
    {
        $matches[$i] = $this->convertVersion($match);
        $matches[$i] = $replace
            ? SemverUtil::replaceAlias($matches[$i], $replace)
            : $matches[$i];
        $matches[$i] .= '~' === $special && \in_array($replace, array('<', '>'), true)
            ? ','.$replace.$matches[$i]
            : '';
        $special = null;
        $replace = null;
    }
1195622
protected function replaceArgumentExpression($matches) {
		//count available matches
		//this indicates the type of expression to replace
		$total_matches = count($matches);
		$type = $subindex = null;
	
		//%{TYPE|CLASS@1}
		if ($total_matches == 2) {
			//check if there are arguments left
			if ($this->counter >= count($this->args))
				throw new \OutOfBoundsException("No arguments left for expression '{$matches[0]}'");

			return $this->castParameter($this->args[$this->counter++], $matches[1]);
		}
	
		switch ($total_matches) {
			/*
			 * Simple index
			 */
			case 5: //%{NUMBER@2[INDEX]@3?:TYPE@4}
				$type = substr($matches[4], 1);
			case 4: //%{NUMBER@2[INDEX]@3}
				$subindex = empty($matches[3]) ? null : substr($matches[3], 1, -1);
			case 3: //%{NUMBER@2}
				$index = intval($matches[2]);
					
				if (!array_key_exists($index, $this->args))
					throw new \InvalidArgumentException("No value found on index $index");
	
				if ($index == 0 && !is_null($subindex))
					return $this->getIndex($subindex, null, $type);
				
				return $this->getSubIndex($this->args[$index], $subindex, $type);
	
			/*
			 * Interval
			 */
			case 10: //%{NUMBER@5[LEFT@7?..RIGHT@8?]:TYPE@9}
				$type = substr($matches[9], 1);
			case 9: //%{NUMBER@5[LEFT@7?..RIGHT@8?]}
				$index = intval($matches[5]);
					
				if (!array_key_exists($index, $this->args))
					throw new \InvalidArgumentException("No value found on index $index");
					
				return $this->getSubRange($this->args[$index], $matches[7], $matches[8], $type);
		}
	}
1342468
public static function hasIdCard($string, &$matches = array(), $ifAll = false) {
		return 0 < self::validateByRegExp("/\d{17}[\d|X]|\d{15}/", $string, $matches, $ifAll);
	}
195662
protected function _replace($matches)
    {
        $file = $this->_currentFile;
        if ($matches[1] === '"') {
            // Same directory include
            $file = $this->_findFile($matches[2], dirname($file) . DIRECTORY_SEPARATOR);
        } else {
            // scan all paths
            $file = $this->_findFile($matches[2]);
        }

        // prevent double inclusion
        if (isset($this->_loaded[$file])) {
            return "";
        }
        $this->_loaded[$file] = true;

        $content = file_get_contents($file);
        if ($return = $this->input($file, $content)) {
            return $return . "\n";
        }
        return '';
    }
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;
	}
97668
function _match($token)
	{
		switch($token) {
			case "+":
			case "-":
			case "*":
			case "/":
			case "(":
			case ")":
			case ",":
			case ";":
			case ">=":
			case "<=":
			case "=":
			case "<>":
			case "^":
			case "&":
			case "%":
				return $token;
				break;
			case ">":
				if ($this->_lookahead == '=') { // it's a GE token
					break;
				}
				return $token;
				break;
			case "<":
				// it's a LE or a NE token
				if (($this->_lookahead == '=') or ($this->_lookahead == '>')) {
					break;
				}
				return $token;
				break;
			default:
				// if it's a reference A1 or $A$1 or $A1 or A$1
				if (preg_match('/^\$?[A-Ia-i]?[A-Za-z]\$?[0-9]+$/',$token) and
				   !preg_match("/[0-9]/",$this->_lookahead) and
				   ($this->_lookahead != ':') and ($this->_lookahead != '.') and
				   ($this->_lookahead != '!'))
				{
					return $token;
				}
				// If it's an external reference (Sheet1!A1 or Sheet1:Sheet2!A1 or Sheet1!$A$1 or Sheet1:Sheet2!$A$1)
				elseif (preg_match("/^" . self::REGEX_SHEET_TITLE_UNQUOTED . "(\:" . self::REGEX_SHEET_TITLE_UNQUOTED . ")?\!\\$?[A-Ia-i]?[A-Za-z]\\$?[0-9]+$/u",$token) and
					   !preg_match("/[0-9]/",$this->_lookahead) and
					   ($this->_lookahead != ':') and ($this->_lookahead != '.'))
				{
					return $token;
				}
				// If it's an external reference ('Sheet1'!A1 or 'Sheet1:Sheet2'!A1 or 'Sheet1'!$A$1 or 'Sheet1:Sheet2'!$A$1)
				elseif (preg_match("/^'" . self::REGEX_SHEET_TITLE_QUOTED . "(\:" . self::REGEX_SHEET_TITLE_QUOTED . ")?'\!\\$?[A-Ia-i]?[A-Za-z]\\$?[0-9]+$/u",$token) and
					   !preg_match("/[0-9]/",$this->_lookahead) and
					   ($this->_lookahead != ':') and ($this->_lookahead != '.'))
				{
					return $token;
				}
				// if it's a range A1:A2 or $A$1:$A$2
				elseif (preg_match('/^(\$)?[A-Ia-i]?[A-Za-z](\$)?[0-9]+:(\$)?[A-Ia-i]?[A-Za-z](\$)?[0-9]+$/', $token) and
					   !preg_match("/[0-9]/",$this->_lookahead))
				{
					return $token;
				}
				// If it's an external range like Sheet1!A1:B2 or Sheet1:Sheet2!A1:B2 or Sheet1!$A$1:$B$2 or Sheet1:Sheet2!$A$1:$B$2
				elseif (preg_match("/^" . self::REGEX_SHEET_TITLE_UNQUOTED . "(\:" . self::REGEX_SHEET_TITLE_UNQUOTED . ")?\!\\$?([A-Ia-i]?[A-Za-z])?\\$?[0-9]+:\\$?([A-Ia-i]?[A-Za-z])?\\$?[0-9]+$/u",$token) and
					   !preg_match("/[0-9]/",$this->_lookahead))
				{
					return $token;
				}
				// If it's an external range like 'Sheet1'!A1:B2 or 'Sheet1:Sheet2'!A1:B2 or 'Sheet1'!$A$1:$B$2 or 'Sheet1:Sheet2'!$A$1:$B$2
				elseif (preg_match("/^'" . self::REGEX_SHEET_TITLE_QUOTED . "(\:" . self::REGEX_SHEET_TITLE_QUOTED . ")?'\!\\$?([A-Ia-i]?[A-Za-z])?\\$?[0-9]+:\\$?([A-Ia-i]?[A-Za-z])?\\$?[0-9]+$/u",$token) and
					   !preg_match("/[0-9]/",$this->_lookahead))
				{
					return $token;
				}
				// If it's a number (check that it's not a sheet name or range)
				elseif (is_numeric($token) and
						(!is_numeric($token.$this->_lookahead) or ($this->_lookahead == '')) and
						($this->_lookahead != '!') and ($this->_lookahead != ':'))
				{
					return $token;
				}
				// If it's a string (of maximum 255 characters)
				elseif (preg_match("/\"([^\"]|\"\"){0,255}\"/",$token) and $this->_lookahead != '"' and (substr_count($token, '"')%2 == 0))
				{
					return $token;
				}
			    // If it's an error code
			    elseif (preg_match("/^#[A-Z0\/]{3,5}[!?]{1}$/", $token) or $token == '#N/A')
			    {
			        return $token;
			    }
				// if it's a function call
				elseif (preg_match("/^[A-Z0-9\xc0-\xdc\.]+$/i",$token) and ($this->_lookahead == "("))
				{
					return $token;
				}
				//	It's an argument of some description (e.g. a named range),
				//		precise nature yet to be determined
				elseif(substr($token,-1) == ')') {
					return $token;
				}
				return '';
		}
	}
1240285
function standardSuffix (token$$1) {

                token$$1.replaceSuffixInRegion([
                  'amentos', 'imentos', 'aço~es', 'adoras', 'adores', 'amento', 'imento',

                  'aça~o', 'adora', 'ância', 'antes', 'ismos', 'istas',

                  'ador', 'ante', 'ável', 'ezas', 'icas', 'icos', 'ismo', 'ista', 'ível',
                  'osas', 'osos',

                  'eza', 'ica', 'ico', 'osa', 'oso'

                  ], '', 'r2');

                token$$1.replaceSuffixInRegion(['logias', 'logia'], 'log', 'r2');

                // token.replaceSuffixInRegion(['uço~es', 'uça~o'], 'u', 'r1');

                token$$1.replaceSuffixInRegion(['ências', 'ência'], 'ente', 'r2');

                token$$1.replaceSuffixInRegion([
                  'ativamente', 'icamente', 'ivamente', 'osamente', 'adamente'
                ], '', 'r2');

                token$$1.replaceSuffixInRegion('amente', '', 'r1');

                token$$1.replaceSuffixInRegion([
                  'antemente', 'avelmente', 'ivelmente', 'mente'
                ], '', 'r2');

                token$$1.replaceSuffixInRegion([
                  'abilidades', 'abilidade',
                  'icidades', 'icidade',
                  'ividades', 'ividade',
                  'idades', 'idade'
                ], '', 'r2');

                token$$1.replaceSuffixInRegion([
                  'ativas', 'ativos', 'ativa', 'ativo',
                  'ivas', 'ivos', 'iva', 'ivo'
                ], '', 'r2');

                if (token$$1.hasSuffix('eiras') || token$$1.hasSuffix('eira')) {
                  token$$1.replaceSuffixInRegion(['iras', 'ira'], 'ir', 'rv');
                }

                return token$$1;
              }
1027052
private function findString($i, array $matches)
    {
        $string = isset($matches[0][$i]) ? $matches[0][$i] : '';


        return substr($string, 1, -1);
    }
618980
public function convertMailLink($matches)
    {
        $email = trim($matches[2]);
        $replacedHrefContent = $this->mailToHrefConverter->convert($email);

        return $matches[1] . htmlspecialchars($replacedHrefContent);
    }
1325186
function tokenizeEvaluate(match, value) {
    var index = tokenized.length;
    tokenized[index] = "';\n" + value + ";\n__p += '";
    return token + index;
  }
250427
protected function formatOpeningParenthesis($token, $i, array &$tokens, array &$originalTokens)
    {
        $length = 0;
        for ($j = 1; $j <= 250; ++$j) {
            if (isset($tokens[$i + $j])) {
                $next = $tokens[$i + $j];
                if ($this->parentheses->stringIsClosingParentheses($next)) {
                    $this->parentheses->writeNewInlineParentheses();
                    break;
                }

                if ($this->parentheses->invalidParenthesesTokenValue($next)
                    || $this->parentheses->invalidParenthesesTokenType($next)
                ) {
                    break;
                }

                $length += \strlen($next[Tokenizer::TOKEN_VALUE]);
            }
        }
        $this->newLine->writeNewLineForLongInlineValues($length);

        if (WhiteSpace::isPrecedingCurrentTokenOfTokenTypeWhiteSpace($originalTokens, $token)) {
            $this->formattedSql = \rtrim($this->formattedSql, ' ');
        }

        $this->newLine->addNewLineAfterOpeningParentheses();

        return $tokens;
    }
1328454
private function substituteFilter($matches)
    {
        if (isset($matches[1]) && isset($this->filters[$matches[1]])) {
            return $this->filters[$matches[1]];
        }
        return "([/][\w-\._@%]*)";
    }
959388
public static function replaceSpecialRange(SemverConverter $converter, $match)
    {
        $newMatch = $converter->convertVersion($match);
        $newMatch = '>='.static::standardizeVersion(SemverUtil::replaceAlias($newMatch, '>')).',<';
        $exp = static::getSplittedVersion($match);
        $increase = false;

        foreach ($exp as $i => $sub) {
            if (static::analyzeSubVersion($i, $exp, $increase)) {
                continue;
            }

            static::increaseSubVersion($i, $exp, $increase);
        }

        $newMatch .= $converter->convertVersion(static::standardizeVersion($exp));

        return $newMatch;
    }
514843
public function match($input, $key, $match, $lang)
    {
        $lang = $this->custom('match', $lang);
        if ($input[$key] !== $input[$match]) {
            return preg_replace_callback('/(\:field)(.*)(\:match)/i',
            function ($m) use ($key, $match) {
                return $key.$m[2].$match;
            }, $lang);
        }
    }