Converts text style tags

@param string $str
@return string $str;
557342
public static function textStyles($str)
    {

        ##bold
        $str = preg_replace("~\[b\](.*?)\[/b\]~is", '<strong class="tb_b">$1</strong>', $str);

        ##sup
        $str = preg_replace("~\[sup\](.*?)\[/sup\]~is", '<sup class="tb_sup">$1</sup>', $str);

        ##sub
        $str = preg_replace("~\[sub\](.*?)\[/sub\]~is", '<sub class="tb_sub">$1</sub>', $str);

        ##italic
        $str = preg_replace("~\[i\](.*?)\[/i\]~is", '<em class="tb_i">$1</em>', $str);

        ##underline
        $str = preg_replace("~\[u\](.*?)\[/u\]~is", '<u class="tb_u">$1</u>', $str);

        ##cite
        $str = preg_replace("~\[cite\](.*?)\[/cite\]~is", '<cite class="tb_cite">$1</cite>', $str);

        ##hilite
        $str = preg_replace("~\[h(?:ilite)?\](.*?)\[/h(?:ilite)?\]~is", '<span class="tb_hilite">$1</span>', $str);

        ##line-though
        $str = preg_replace("~\[strike](.*?)\[/strike]~is", '<del class="tb_strike">$1</del>', $str);

        ## add small caps
        $str = preg_replace("~\[caps](.*?)\[/caps]~is", '<span class="tb_caps">$1</span>', $str);

        ## add center
        $str = preg_replace("~\[center](.*?)\[/center]~is", '<center class="tb_center">$1</center>', $str);

        ## add code tag
        ## add small caps
        $str = preg_replace("~\[code](.*?)\[/code]~is", '<pre style="background-color:black;color:green;overflow:auto;">$1</pre>', $str);

        ## font size
        $r = "~\[size=([\d(?:\.\d+)]+(?:em|px)?)\](.*?)\[\/size\]~is";
        while(preg_match($r, $str)){
            $str = preg_replace($r, '<span style="font-size:\\1;">\\2</span>', $str);
        }

        ## font size
        $r = "~\[size=(small|medium|large)\](.*?)\[\/size\]~is";
        while(preg_match($r, $str)){
            $str = preg_replace($r, '<span style="font-size:\\1;">\\2</span>', $str);
        }

        ## font color
        $r = "~\[color=(.*?)\](.*?)\[\/color\]~is";
        while(preg_match($r, $str)){
            $str = preg_replace($r, '<span style="color:\\1;">\\2</span>', $str);
        }

        return $str;
    }
110946
public function parse($str)
	{
		if ($this->isQuoteHtml() === true)
		{
			$str = htmlspecialchars($str, ENT_QUOTES);
		}

		foreach ($this->getBbCodes() as $key => $val)
		{
			$str = preg_replace($key, $val, $str);
		}

		return $str;
	}
362780
function token($str) {
		$str=preg_replace_callback(
			'/(?<!\w)@(\w(?:[\w\.\[\]])*)/',
			function($token) {
				// Convert from JS dot notation to PHP array notation
				return '$'.preg_replace_callback(
					'/(\.\w+)|\[((?:[^\[\]]*|(?R))*)\]/',
					function($expr) {
						$fw=\Base::instance();
						return
							'['.
							($expr[1]?
								$fw->stringify(substr($expr[1],1)):
								(preg_match('/^\w+/',
									$mix=$this->token($expr[2]))?
									$fw->stringify($mix):
									$mix)).
							']';
					},
					$token[1]
				);
			},
			$str
		);
		return trim($str);
	}
835641
static public function fromCamel($str) {
      $str[0] = strtolower($str[0]);
      return preg_replace_callback('/([A-Z])/', function($char) {return "_" . strtolower($char[1]);}, $str);
  }
1024539
public static function encode(String $str) : String
    {
        return preg_replace
        (
            array_keys(self::$scriptTagChars), 
            array_values(self::$scriptTagChars), 
            $str
        );
    }
1110372
public static function toAscii(string $str) : string
    {
        $clean = preg_replace('/[^a-zA-Z0-9\.\/_|+ -]/', '', $str);
        $clean = strtolower(trim($clean, '-'));
        $clean = preg_replace('/[\/_|+ -]+/', '-', $clean);

        return $clean;
    }
1180679
public static function humanize(string $str): string
    {
        $result = preg_replace(
            [
                '/([A-Z])/',
                '/[-\s]+/',
                '/[_\s]+/',
            ],
            [
                '_$1',
                ' ',
                ' ',
            ],
            static::removeMultipleSpaces($str)
        );

        return mb_ucfirst(mb_strtolower($result));
    }
642761
protected function parseTags($str, $tags)
    {
        // Let's keep a history of styles applied
        $history = ($this->currentCode()) ? [$this->currentCode()] : [];

        foreach ($tags as $tag) {
            $str = $this->replaceTag($str, $tag, $history);
        }

        return $str;
    }
635070
public static function decode(String $str) : String
    {
        return preg_replace
        (
            array_keys(self::$scriptTagCharsDecode), 
            array_values(self::$scriptTagCharsDecode), 
            $str
        );
    }
285666
private function toCamelCase($str)
    {
        // Split string in words.
        $words = preg_split('/[-_]/', strtolower($str)); //explode('_', strtolower($str));

        $return = '';
        foreach ($words as $word) {
            $return .= ucfirst(trim($word));
        }

        return $return;
    }
840637
protected function tabilize($str)
    {
        $str[0] = strtolower($str[0]);
        $func = create_function('$c', 'return "_" . strtolower($c[1]);');

        return preg_replace_callback('/([A-Z])/', $func, $str);
    }
1137365
public static function convertXMLValueToString(string $str) : string
    {
        $str = str_replace("&amp;", "&", $str);
        $str = str_replace("&lt;", "<", $str);
        $str = str_replace("&gt;", ">", $str);
        $str = str_replace("&apos;", "'", $str);
        $str = str_replace("&quot;", "\"", $str);

        return $str;
    }
532975
public static function stripAll($str)
	{
		return self::stripScripts(
			self::stripImages(
				self::stripTags(
					self::stripWhitespace($str)
				)
			)
		);
	}
938461
protected function preTransliterate($str)
    {
        $str = $this->escapeLatinCharacters($str);
        $str = mb_convert_kana($str, 'c', 'UTF-8');

        return $str;
    }
1279230
public static function makeHTMLString($str)
    {

        $str = trim($str);
        $str = htmlspecialchars($str, ENT_COMPAT, 'utf-8');

        return nl2br($str);
    }
1351774
public static function decorateTT($str)
    {
        $str = htmlspecialchars($str, ENT_QUOTES);
        $str = preg_replace('/`([^`]*)`/', '<tt>\\1</tt>', $str);

        return $str;
    }
821240
public static function extract($str)
    {
        preg_match_all("/(^|[\n ])#([a-z0-9_-]*)/is", $str, $matches);

        if (!is_array($matches) || !count($matches)) {
            return [];
        }

        $hashtags = [];
        foreach ($matches[0] as $match) {
            $match = ltrim(trim($match), '#_ ');
            if (self::isValid($match)) {
                $hashtags[strtolower($match)] = $match;
            }
        }

        return array_values($hashtags);
    }