Parses the supplied hex string into an array of channels.

@param string $string

@return \int[] eg: [100, 100, 100]
@throws InvalidArgumentException
966377
public static function parseHexString(string $string) : array
    {
        if (!preg_match(self::REGEX_HEX, $string, $matches)) {
            throw InvalidArgumentException::format(
                    'Invalid rgba string passed to %s: expecting format "#...", "%s" given',
                    __METHOD__, $string
            );
        }

        $string = str_replace('#', '', $string);

        if (strlen($string) === 3) {
            $r = hexdec($string[0] . $string[0]);
            $g = hexdec($string[1] . $string[1]);
            $b = hexdec($string[2] . $string[2]);
        } else {
            $r = hexdec($string[0] . $string[1]);
            $g = hexdec($string[2] . $string[3]);
            $b = hexdec($string[4] . $string[5]);
        }

        return [(int)$r, (int)$g, (int)$b];
    }
1008381
public static function str_to_hex($string) {
        $hex = '';

        for ($i = 0; $i < strlen($string); $i++) {
            $hex .= dechex(ord($string[$i]));
        }

        return $hex;
    }
586736
protected function _parse_string($string, $single_trim = false) {
    if ($single_trim) {
      $string = preg_replace("/^[\"\']/", "", $string);
      $string = preg_replace("/[\"\']$/", "", $string);
    }
    else {
      $string = trim($string, "'\"");
    }
    
    $string = str_replace(array("\\\n",'\\"',"\\'"),
                          array("",'"',"'"), $string);

    // Convert escaped hex characters into ascii characters (e.g. \A => newline)
    $string = preg_replace_callback("/\\\\([0-9a-fA-F]{0,6})(\s)?(?(2)|(?=[^0-9a-fA-F]))/",
                                    create_function('$matches',
                                                    'return chr(hexdec($matches[1]));'),
                                    $string);
    return $string;
  }
1117436
public function parseString($string, $values)
    {
        $positions = [];
        $pos = 0;
        $offset = 0;

        while (($pos = strpos($string, "?", $offset)) !== false) {
            $positions[] = $pos;
            $offset = $pos + 1;
        }

        $count = count($positions);

        if ($count == 1) {
            $values = array($values);
        }

        for ($i = 0; $i < $count; $i++) {
            $value = $values[$i];
            if ($value instanceof Query) {
                $value = $this->parseValueQuery($value);
            } elseif (is_array($value)) {
                foreach ($value as $key => $subvalue) {
                    if (trim($subvalue) != '') {
                        $value[$key] = is_numeric($subvalue) ? $subvalue : $this->getQuery()->getManager()->getAdapter()->quote($subvalue);
                    } else {
                        unset($value[$key]);
                    }
                }
                $value = "(" . implode(", ", $value) . ")";
            } elseif (is_numeric($value)) {
            } else {
                $value = $this->getQuery()->getManager()->getAdapter()->quote($values[$i]);
            }
            $string = substr_replace($string, $value, strpos($string, '?'), 1);
        }

        return $string;
    }
2717
public function parseString($string)
    {
        if (!mb_strlen($string)) {
            throw new \InvalidArgumentException('Option string must not be empty');
        }
        $options = array();
        $eol = mb_strlen($string) - 1;
        $nextCanBeColon = false;
        for ($i = 0; $i <= $eol; ++$i) {
            $ch = $string[$i];
            if (!preg_match('/^[A-Za-z0-9]$/', $ch)) {
                $colon = $nextCanBeColon ? " or ':'" : '';
                throw new \InvalidArgumentException("Option string is not well formed: "
                    ."expected a letter$colon, found '$ch' at position ".($i + 1));
            }
            if ($i == $eol || $string[$i + 1] != ':') {
                $options[] = new Option($ch, null, Getopt::NO_ARGUMENT);
                $nextCanBeColon = true;
            } elseif ($i < $eol - 1 && $string[$i + 2] == ':') {
                $options[] = new Option($ch, null, Getopt::OPTIONAL_ARGUMENT);
                $i += 2;
                $nextCanBeColon = false;
            } else {
                $options[] = new Option($ch, null, Getopt::REQUIRED_ARGUMENT);
                ++$i;
                $nextCanBeColon = true;
            }
        }
        return $options;
    }
1036165
public static function stringToArray($string)
    {
        if (!preg_match("@^{.*?}$@", $string)) {
            return $string;
        }
        $parts = explode(',', substr($string, 1, -1));
        foreach ($parts as &$part) {
            $part = self::stringToArray($part);
        }
        return $parts;
    }
1176130
public function parseString($string)
    {
        $tokens = new Stack($this->tokenizer->tokenize($string));

        if ($tokens[0]->type === Tokenizer::T_EOF) {
            return new CTX\AccountInfoList();
        }

        $ctx = new CTX();
        $this->reduceStruct($tokens, $ctx);

        return $ctx->accountInfoList[0];
    }
855601
public function decode($string)
    {
        $i = 0;

        foreach(str_split($string) as $char)
        {
            $i = $i * $this->radix + array_search($char, $this->dictionary);
        }

        return $i;
    }
1220215
public static function stringToValueAndUnit(string $string): array
    {
        preg_match('/^([0-9.]+)([µa-zA-Z]+)$/', $string, $matches);
        $value = (float) $matches[1];
        $unit = Mapper::getUnitFromAbbreviation($matches[2]);
        return [$value, $unit];
    }
1182100
public function stringPermutations(string $string): array {
        $result = [];
        $strLen = \strlen($string);
        if (0 === $strLen) {
            return $result;
        }
        if (1 === $string) {
            $result[] = $string;
            return $result;
        }
        $array = StringUtil::stringToArray($string);

        $result = $this->permute($array, "", $result);
        return $result;
    }
221075
static function Parse($string) {
        $result = null;
        if (!self::TryParse($string, $result)) {
            throw new \InvalidArgumentException("'$string' could not be converted to a number");
        }
        return $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 [];
        }
    }
631899
protected function _parseAttributes($string)
    {
        $result = array();

        if (!empty($string)) {
            $attr   = array();

            preg_match_all('/([\w:-]+)[\s]?=[\s]?"([^"]*)"/i', $string, $attr);

            if (is_array($attr)) {
                $numPairs = count($attr[1]);
                for ($i = 0; $i < $numPairs; $i++) {
                    $result[$attr[1][$i]] = $attr[2][$i];
                }
            }
        }

        return $result;
    }
1049358
protected function parseSegments($string) {
        preg_match_all(
            '/^' .
            '((?P<protocol>.*):\/\/)?' .
            '(' .
                '(?P<username>.*?)' .
                '(:(?P<password>.*?)' .
            ')@)?' .
            '(?P<host>[^:\/\s]+)?' .
            '(:(?P<port>\d*))?' .
            '(?P<path>[^#\?]*)?' .
            '(\?(?P<query>[^#]*))?' .
            '(#(?P<fragment>.*))?' .
            '$/',
            $string,
            $segments
        );

        foreach ($segments as $key => $value) {
            if (is_numeric($key)) {
                unset($segments[$key]);
            } else {
                $segments[$key] = array_pop($value);
            }
        }

        $host = array_get($segments, 'host');

        if ($host && $host !== 'localhost' && stripos($host, '.') === false) {
            $segments['path'] = '/' . $host . array_get($segments, 'path');
            $segments['host'] = null;
        }

        return $segments;
    }
772179
public function parseAttributes($string)
    {
        $result = array();

        if (!empty($string))
        {
            $pattern = '#(?(DEFINE)
                (?<name>[a-zA-Z][a-zA-Z0-9-_:]*)
                (?<value_double>"[^"]+")
                (?<value_none>[^\s>]+)
                (?<value>((?&value_double)|(?&value_none)))
            )
            (?<n>(?&name))[\s]*(=[\s]*(?<v>(?&value)))?#xs';

            if (preg_match_all($pattern, $string, $matches, PREG_SET_ORDER))
            {
                foreach ($matches as $match) {
                    if (!empty($match['n'])) {
                        $result[$match['n']] = isset($match['v']) ? trim($match['v'], '\'"') : '';
                    }
                }
            }
        }

        return $result;
    }
176502
public static function fromString($string)
    {
        $matches = array();
        $valid = \preg_match(
            '#^([-,\+])?([0-9]*[\.\/]?[0-9]*)([-,\+]){1}([0-9]*[\.\/]?[0-9]*)i$#',
            \trim($string),
            $matches
        );

        if ($valid !== 1) {
            throw new \InvalidArgumentException(
                'The string representation of the complex number is invalid.'
            );
        }

        $real = $matches[2];
        $imaginary = $matches[4];

        if ($matches[1] && $matches[1] == '-') {
            $real = '-' . $real;
        }
        if ($matches[3] && $matches[3] == '-') {
            $imaginary = '-' . $imaginary;
        }
        
        return self::create(self::convertType($real), self::convertType($imaginary));
    }
787723
private function parseQuery($string)
    {
        $return = array();
        $parts = explode("&", $string);
        foreach ($parts as $part) {
            list($key, $value) = explode('=', $part, 2);
            $value = urldecode($value);
            if (isset($return[$key])) {
                if (!is_array($return[$key])) {
                    $return[$key] = array($return[$key]);
                }
                $return[$key][] = $value;
                continue;
            }
            $return[$key] = $value;
        }
        return $return;
    }