Parses a CSS string and returns sheet structure statically.
@access		public
@param		string			$string		CSS string
@return		ADT_CSS_Sheet
171364
static public function parseString( $string ){
		if( substr_count( $string, "{" ) !== substr_count( $string, "}" ) )							//  
			throw Exception( 'Invalid paranthesis' );
		$string	= preg_replace( '/\/\*.+\*\//sU', '', $string );
		$string	= preg_replace( '/(\t|\r|\n)/s', '', $string );
		$state	= (int) ( $buffer = $key = '' );
		$sheet	= new ADT_CSS_Sheet();
		for( $i=0; $i<strlen( $string ); $i++ ){
			$char = $string[$i];
			if( !$state && $char == '{' ){
				$state	= (boolean) ( $key = trim( $buffer ) );
				$buffer	= '';
			}
			else if( $state && $char == '}' ){
				$properties	= self::parseProperties( $buffer );
				foreach( explode( ',', $key ) as $selector )
					$sheet->addRule( new ADT_CSS_Rule( $selector, $properties ) );
				$state	= (boolean) ($buffer = '');
			}
			else
				$buffer	.= $char;
		}
		return $sheet;
	}
708403
public function css($string)
    {
        if (!$string) {
            return $string;
        }

        $string = $this->toUtf8($string);
        if ($string === '' || ctype_digit($string)) {
            return $string;
        }

        $result = preg_replace_callback('/[^a-z0-9]/iSu', $this->cssMatcher, $string);
        return $this->fromUtf8($result);
    }
957762
protected function parseString(/*# string */ $string)/*# : array */
    {
        $regex =
        '~^\s*+
            (?:
                (?:([^#\s=]++) \s*+ = \s*+
                    (?|
                        (([^"\'#\s][^#\n]*?)) |
                        (["\'])((?:\\\2|.)*?)\2
                    )?
                ) |
                (?: (\.|source) \s++ ([^#\n]*) )
            )\s*?(?:[#].*)?
        $~mx';

        if (preg_match_all($regex, $string, $matched, \PREG_SET_ORDER)) {
            return $this->clearPairs($matched);
        } else {
            return [];
        }
    }
382350
public static function parse($string)
    {
        $matches = Regex::matchSemVer($string);

        // Parse the SemVer root
        $version = VersionableParser::parse(
            $matches[1],
            'Naneau\SemVer\Version'
        );

        // There is a pre-release part
        if (!empty($matches['prerelease'])) {
            $version->setPreRelease(
                PreReleaseParser::parse(
                    ltrim($matches['prerelease'], '-')
                )
            );
        }

        // There is a build number
        if (!empty($matches['build'])) {
            $version->setBuild(
                BuildParser::parse(
                    ltrim($matches['build'], '+')
                )
            );
        }

        // Return
        $version->setOriginalVersion($string);
        return $version;
    }
261118
public static function strip($string)
    {
        $cleaned = strip_tags($string);
        $cleaned = Str::trim($cleaned);

        return $cleaned;
    }
112285
public function process($string)
    {
        preg_match_all($this->tagFilter, $string, $matches);

        if (!$matches) {
            return $string;
        }

        foreach ($matches[0] as $i => $m) {
            if (array_key_exists($matches[1][$i], $this->styles)) {
                $string = $this->replaceColors(
                    $string,
                    $matches[1][$i],
                    $matches[2][$i],
                    $this->styles[$matches[1][$i]]
                );
            } elseif (strpos($matches[1][$i], '=')) {
                // Custom format
                $string = $this->replaceColors(
                    $string,
                    $matches[1][$i],
                    $matches[2][$i],
                    ColorStyle::fromString($matches[1][$i])
                );
            }
        }

        return $string;
    }
75197
public function _($string)
    {
        $this->setTraceLevelOffset(1);

        $result = $this->translate($string);

        $this->setTraceLevelOffset(0);

        return $result;
    }
1368449
private function createStyleFromString(string $string)
    {
        if (isset($this->styles[$string])) {
            return $this->styles[$string];
        }

        if (!preg_match_all('/([^=]+)=([^;]+)(;|$)/', $string, $matches, PREG_SET_ORDER)) {
            return false;
        }

        $style = new OutputFormatterStyle();
        foreach ($matches as $match) {
            array_shift($match);
            $match[0] = strtolower($match[0]);

            if ('fg' == $match[0]) {
                $style->setForeground(strtolower($match[1]));
            } elseif ('bg' == $match[0]) {
                $style->setBackground(strtolower($match[1]));
            } elseif ('href' === $match[0]) {
                $style->setHref($match[1]);
            } elseif ('options' === $match[0]) {
                preg_match_all('([^,;]+)', strtolower($match[1]), $options);
                $options = array_shift($options);
                foreach ($options as $option) {
                    $style->setOption($option);
                }
            } else {
                return false;
            }
        }

        return $style;
    }
127766
public function parseKeyword($string)
    {
        $matches = $this->parseKeywordText($string);
        return $this->parseKeywordToText($matches['keywords'], $matches['alias']);
    }
895608
private function parseHtmlText($string, array $styles = null)
    {
        $styles = $styles==null ? [] : $styles;
        $styles = $this->normalizeStyles($styles);

        $string = "" . $string;

        // https://phpspreadsheet.readthedocs.io/en/develop/topics/recipes/#add-rich-text-to-a-cell

        // Encontra as tags b, u, i
        $richs = [];
        preg_match_all("/<[b|u|i|s]>(.*?)<\/[b|u|i|s]>/", $string, $richs);

        // Separa o texto em partes
        $strips = [];
        $strip_styles = [];
        $last = '';
        foreach ($richs[0] as $index => $tagged) {

            $split = explode($tagged, $string);
            $strips[] = $split[0]; // adicona conteudo texto anterior à tag
            $strip_styles[] = 't';
            $strips[] = $richs[1][$index]; // adiciona conteudo da tag
            $strip_styles[] = substr($tagged, 1, 1);
            $string = $split[1]; // atualiza a string
        }

        if (!empty($string)) {
            $strips[] = $string; // adicona conteudo texto anterior à tag
            $strip_styles[] = 't';
        }

        // Armazena os pedaços o texto sem as tags
        // para o debugger capturar
        $this->last_text_content = implode('', $strips);

        $text = new \PhpOffice\PhpSpreadsheet\RichText\RichText();

        $color = $this->createColor($styles['color']);

        foreach ($strips as $k => $value) {

            switch($strip_styles[$k]) {
                case 't':
                    $t = $text->createTextRun($value);
                    $t->getFont()->setColor($color);
                    $t->getFont()->setName($styles['font-face']);
                    $t->getFont()->setSize($styles['font-size']);
                    break;
                case 'b':
                    $b = $text->createTextRun($value);
                    $b->getFont()->setBold(true);
                    $b->getFont()->setColor($color);
                    $b->getFont()->setName($styles['font-face']);
                    $b->getFont()->setSize($styles['font-size']);
                    break;
                case 'i':
                    $i = $text->createTextRun($value);
                    $i->getFont()->setItalic(true);
                    $i->getFont()->setColor($color);
                    $i->getFont()->setName($styles['font-face']);
                    $i->getFont()->setSize($styles['font-size']);
                    break;
                case 'u':
                    $u = $text->createTextRun($value);
                    $u->getFont()->setUnderline(true);
                    $u->getFont()->setColor($color);
                    $u->getFont()->setName($styles['font-face']);
                    $u->getFont()->setSize($styles['font-size']);
                    break;
                case 's':
                    $s = $text->createTextRun($value);
                    $s->getFont()->setStrikethrough(true);
                    $s->getFont()->setColor($color);
                    $s->getFont()->setName($styles['font-face']);
                    $s->getFont()->setSize($styles['font-size']);
                    break;
            }
        }

        return $text;
    }
483704
public function format($string) {
        if ($this->isAnsiEnabled()) {
            return $this->formatAnsi($string);
        }

        return $this->formatPlain($string);
    }
1258744
public static function parse($string)
    {
        // Explode over '.'
        $parts = explode('.', $string);

        // Instantiate
        $buildVersion = new BuildVersion;

        // No parts is no build?
        if (count($parts) === 0) {
            return $buildVersion;
        }

        // Discard "build" string should it prepend the build
        if ($parts[0] === 'build') {
            array_shift($parts);
        }

        // If the first part is a number it's the build number
        if (isset($parts[0]) && is_numeric($parts[0])) {
            $buildVersion->setNumber(
                (int) array_shift($parts)
            );
        }

        // All other parts are custom and can simply be put on a stack
        foreach ($parts as $part) {
            $buildVersion->addPart($part);
        }

        // Return
        return $buildVersion;
    }
1164094
protected function parseString($string) {
        $matches = [];

        if (preg_match_all($this->regex, $string, $result) !== false) {
            $matches = $result[0];
        }

        return $matches;
    }
282075
public static function parseStringForSearch($string)
    {
        $words = explode(' ', $string);
        $conditions = [];

        foreach ($words as $word) {
            $word = trim($word);

            if (empty($word)) {
                continue;
            }

            if (is_numeric($word)) {
                $conditions[] = $word;
                continue;
            }

            if (1 === mb_strlen($word)) {
                continue;
            }

            if (mb_strlen($word) > 7) {
                $conditions[] = mb_substr($word, 0, -3, 'UTF-8');
                continue;
            }

            if (mb_strlen($word) > 5) {
                $conditions[] = mb_substr($word, 0, -1, 'UTF-8');
                continue;
            }

            if (in_array(mb_substr($word, -1, null, 'UTF-8'), ['ě', 'š', 'č', 'ř', 'ž', 'ý', 'á', 'í', 'é', 'ú', 'ů'], true)) {
                $conditions[] = mb_substr($word, 0, -1, 'UTF-8');
                continue;
            }

            $conditions[] = $word;
        }

        return $conditions;
    }
1159029
public static function parse($string, array $styles)
    {
        // style the entire string if no tags are found
        if (false === strpos($string, '{')) {
            return self::style($string, reset($styles));
        }

        $i = 0;

        // loop through each tag in the string
        while (false !== $openTag = strpos($string, '{')) {
            $style = array_key_exists($i, $styles) ? $styles[$i] : end($styles);

            $escapeSequence = ($style instanceof Style) ? $style->getEscapeSequence() : self::getEscapeSequence($style);
            $resetSequence = ($style instanceof Style) ? Style::getResetSequence() : self::getResetSequence($style);

            // replace opening tag
            $string = substr_replace($string, $escapeSequence, $openTag, 1);

            if (false === $closeTag = strpos($string, '}')) {
                $closeTag = strlen($string);
            }

            // don't produce multiple identical reset tags next to each other
            if (substr($string, $closeTag - strlen($resetSequence), strlen($resetSequence)) !== $resetSequence) {
                $string = substr_replace($string, $resetSequence, $closeTag, 1);
            }

            $i++;
        }

        return $string;
    }
162895
public function parseString($string)
    {
        //argument 1 must be a string
        Argument::i()->test(1, 'string');
        
        foreach ($this->data as $key => $value) {
            $string = str_replace($key, $value, $string);
        }

        return $string;
    }
623502
public function parseHtml( $string )
	{
		$this->document = new DOMDocument();
		ob_start();
		$this->document->loadHTML( $string );
		$content	= ob_get_clean();
		if( $content )
			$this->errors	= $content;
	}