Censor a word if its only by itself.

@param array $matches
@return string
161234
protected function _censorCallback($matches) {
        $length = mb_strlen(trim($matches[0]));
        $censored = '';
        $symbols = str_shuffle('*@#$*!?%');
        $i = 0;
        $s = 0;

        if ($length > 10) {
            $length = 10;
        }

        while ($i < $length) {
            $censored .= $symbols[$s];

            $i++;
            $s++;

            if ($s > 7) {
                $s = 0;
            }
        }

        return $censored;
    }
908699
protected function matchToKeys(array $matches)
    {
        $parameterNames = $this->parameterNames();

        if (count($parameterNames) == 0) {
            return array();
        }

        $parameters = array_intersect_key($matches, array_flip($parameterNames));

        return array_filter($parameters, function ($value)
        {
            return is_string($value) && (strlen($value) > 0);
        });
    }
139549
protected function cssEscaper(array $matches): string
	{
		$chr = $matches[0];

		if(strlen($chr) === 1)
		{
			$ord = ord($chr);
		}
		else
		{
			$chr = mb_convert_encoding($chr, 'UTF-16BE', 'UTF-8');

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

		return sprintf('\\%X ', $ord);
	}
266713
protected function javascriptEscaper(array $matches): string
	{
		$chr = $matches[0];

		if(strlen($chr) === 1)
		{
			return sprintf('\\x%02X', ord($chr));
		}

		$chr = mb_convert_encoding($chr, 'UTF-16BE', 'UTF-8');

		return sprintf('\\u%04s', strtoupper(bin2hex($chr)));
	}
300809
protected function parseDocLicense( $matches )
	{
		$name	= NULL;
		$url	= NULL;
		if( isset( $matches[2] ) )
		{
			$url	= trim( $matches[1] );
			$name	= trim( $matches[2] );
			if( preg_match( "@^http://@", $matches[2] ) )
			{
				$url	= trim( $matches[2] );
				$name	= trim( $matches[1] );
			}
		}
		else
		{
			$name	= trim( $matches[1] );
			if( preg_match( "@^http://@", $matches[1] ) )
				$url	= trim( $matches[1] );
		}
		$license	= new ADT_PHP_License( $name, $url );
		return $license;
	}
499507
function Censoring() {

    /**
     * The string to replaces found matches with. Defaults to ***
     *
     * @type {String}
     */
    this.replacementString = '***';

    /**
     * The color used for highlighting
     *
     * @type {string}
     */
    this.highlightColor = 'F2B8B8';

    /**
     * Holds the currently matched text.
     *
     * @type {{replace: string, hasMatches: boolean}}
     */
    this.currentMatch = {
      replace: '',
      hasMatches: false,
      matches: []
    };

    /**
     * The available patterns. These are as follows:
     *  [name]              [description]
     *  - long_number       ; Matches long, consecutive numbers
     *  - phone_number      ; Matches phone numbers.
     *  - email_address     ; Matches email addresses in many formats.
     *  - url               ; Matches URL patterns/
     *  - words             ; Finds words, even when in disguise.
     *
     * @type {{long_number: {pattern: RegExp, enabled: boolean}, phone_number: {pattern: RegExp, enabled: boolean}, email_address: {pattern: RegExp, enabled: boolean}, url: {pattern: RegExp, enabled: boolean}, words: {enabled: boolean, pattern: Array}}}
     */
    this.patterns = {
      long_number: {
        pattern: /\d{8,}/,
        enabled: false
      },
      phone_number: {
        pattern: /([+-]?[\d]{1,}[\d\s-]+|\([\d]+\))[-\d.\s]{8,}/gi,
        enabled: false
      },
      email_address: {
        pattern: /[\w._%+-]+(@|\[at\]|\(at\))[\w.-]+(\.|\[dot\]|\(dot\)|\(punt\)|\[punt\])[a-zA-Z]{2,4}/gi,
        enabled: false
      },
      url: {
        pattern: /((https?:\/{1,2})?([-\w]\.{0,1}){2,}(\.|\[dot\]|\(dot\)|\(punt\)|\[punt\])([a-zA-Z]{2}\.[a-zA-Z]{2,3}|[a-zA-Z]{2,4}).*?(?=$|[^\w\/-]))/gi,
        enabled: false
      },
      words: {
        pattern: [],
        enabled: false
      }
    };

    /**
     * A mapping that maps regular characters to 1337 characters.
     *
     * @type {{o: string, g: string, b: Array, t: string, s: string, a: string, e: string, z: string, i: string, l: string}}
     */
    this.map1337 = {
      o: '0',
      g: '9',
      b: ['8', '6'],
      t: '7',
      s: '5',
      a: '4',
      e: '3',
      z: '2',
      i: '1',
      l: '1'
    };
  }
618980
public function convertMailLink($matches)
    {
        $email = trim($matches[2]);
        $replacedHrefContent = $this->mailToHrefConverter->convert($email);

        return $matches[1] . htmlspecialchars($replacedHrefContent);
    }
714216
public static function stripTags($text, array $allowed = array())
    {
        // Based on [fernando at zauber dot es]'s solution
        $allowed = array_map('strtolower', $allowed);

        return preg_replace_callback('/<\/?([^>\s]+)[^>]*>/i', function ($matches) use (&$allowed) {
            return in_array(strtolower($matches[1]), $allowed) ? $matches[0] : '';
        }, $text);
    }
716332
protected function placeHolder(array $matches)
    {
        $placeholder = '%{{' . md5(time() . count($this->holder) . mt_rand(0, 500)) . '}}%';
        $this->holder[$placeholder] = $matches['1'];

        return $placeholder;
    }
1230234
protected static function h(array $matches)
    {
        $level = strlen($matches[1]);
        return sprintf('<h%d>%s</h%d>', $level, trim($matches[2]), $level);
    }
1302031
protected function removeNumericAndEmpty(array &$matches)
    {
        foreach ($matches as $idx => $val) {
            if (is_int($idx) || '' === $val) {
                unset($matches[$idx]);
            }
        }
    }
217155
private static function jsMatcher($matches) {

        $chr = $matches[0];

        if(1 === strlen($chr)) {
            return sprintf('\\x%02X', ord($chr));
        }

        $chr = static :: convert($chr, 'UTF-8', 'UTF-16BE');
        $hex = strtoupper(bin2hex($chr));

        if(strlen($hex) <= 4) {
            return sprintf('\\u%04s', $hex);
        }

        return sprintf('\\u%04s\\u%04s', substr($hex, 0, 4), substr($hex, 4, 4));
    }
31584
protected function doReplaceNameInExpression($matches)
    {
        $key = $matches[0];
        list($column, $realFullColumnName) = $this->getColumnFromName($key);

        if ($column instanceof ColumnMap) {
            $this->replacedColumns[] = $column;
            $this->foundMatch = true;

            if (false !== strpos($key, '.')) {
                list($tableName, $columnName) = explode('.', $key);
                $realColumnName = substr($realFullColumnName, strrpos($realFullColumnName, '.') + 1);
                if (isset($this->aliases[$tableName])) {
                    //don't replace a alias with their real table name
                    return $this->quoteIdentifier($tableName.'.'.$realColumnName);
                }
            }

            return $this->quoteIdentifier($realFullColumnName);
        }

        return $this->quoteIdentifier($key);
    }
33022
protected function _stripAbbreviations_callback($matches) {
		$abbr_word = $matches[1];
		$abbr_desc = $matches[2];
		if ($this->abbr_word_re) {
			$this->abbr_word_re .= '|';
		}
		$this->abbr_word_re .= preg_quote($abbr_word);
		$this->abbr_desciptions[$abbr_word] = trim($abbr_desc);
		return ''; // String that will replace the block
	}
386246
private function _filter(array $matches)
    {
        $filters = explode('|', $matches[0]);
        $var = $filters[0];
        unset($filters[0]);
        foreach ($filters as $filter) {
            $params = explode(':', $filter);
            $filterName = $params[0];
            unset($params[0]);
            $array = 'array(';
            foreach ($params as $param) {
                $array .= $param . ',';
            }
            $array = trim($array, ',') . ')';
            $var = 'getFilter(\'' . $filterName . '\')->setOptions(' . $array . ')->filter(' . $var . ')';
        }
        return $var;
    }
1017042
private static function cssMatcher($matches) {

        $chr = $matches[0];

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

        return sprintf('\\%X ', $ord);
    }
428611
protected function _processCodeBlock($matches)
    {
        list($block, $openTag, $tagName, $lang, $code, $closeTag) = $matches;
        unset($matches);

        // check language
        $lang = $this->validLang($lang);
        $code = html_entity_decode($code, ENT_QUOTES); // decode text in code block as GeSHi will re-encode it.

        if (isset($this->containerMap[$tagName])) {
            $patt = '/' . preg_quote($tagName) . '/';
            $openTag = preg_replace($patt, $this->containerMap[$tagName][0], $openTag);
            $closeTag = preg_replace($patt, $this->containerMap[$tagName][1], $closeTag);
        }

        if ($this->showPlainTextButton) {
            $button = '<a href="#null" class="geshi-plain-text">Show Plain Text</a>';
            $openTag = $button . $openTag;
        }

        if ($lang) {
            $highlighted = $this->highlightText(trim($code), $lang);
            return $openTag . $highlighted . $closeTag;
        }
        return $openTag . $code . $closeTag;
    }