Splits number string into individual digits.
@param string $string String to split into array of digits
@return array Array of digits
@throws \RuntimeException If numeral system does not support strings
358854
public function splitString($string)
    {
        if ($this->digits->hasStringConflict()) {
            throw new \RuntimeException('The number base does not support string presentation');
        }

        $pattern = $this->getDigitPattern();

        if ((string) $string === '') {
            $digits = [];
        } elseif (is_int($pattern)) {
            $digits = str_split($string, $this->digitPattern);
        } else {
            preg_match_all($pattern, $string, $match);
            $digits = $match[0];
        }

        return $this->canonizeDigits($digits);
    }
1291231
public function tokenize($string)
    {
        $matches = array();
        $count = preg_match_all($this->pattern, $string, $matches, $this->flags, $this->offset);
        if($count === false) { 
            return array();
        }
        return $matches[0];
        
    }
169980
public function parseString($string)
    {
        $tokens = $this->tokenize($string);

        $tokens = array_filter(
            $tokens,
            function ($token) {
                return !($token['type'] === TransformationProcessor::T_WHITESPACE ||
                          $token['type'] === TransformationProcessor::T_COMMENT);
            }
        );

        $ast = array();
        $section = null;
        while ($token = array_shift($tokens)) {
            if ($token['type'] === TransformationProcessor::T_SECTION) {
                $section = $token['data']['section'];
                continue;
            }

            if ($section === null) {
                throw new RuntimeException('Expected section.');
            }

            $ast[$section][] = $token;
        }

        return $ast;
    }
997478
private static function strord( $string )
	{ 
		for( $i=0; $i<strlen( $string ); $i++ )
		{ 
			$result[$i] = ord( $string{$i} );
		}
		return $result;
	}
760005
public function getHtmlByMarkdown($string)
    {
        if (false === class_exists('\Parsedown')) {
            throw new \RuntimeException('Missing Parsedown. Try: composer require "erusev/parsedown" "^1.6.1"');
        }

        $parse = new Parsedown();
        $parse->setBreaksEnabled($this->isParameterParseDownBreaksEnabled());

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

        return $this->formatPlain($string);
    }
1121268
public function parseString($string)
    {
        $value = $this->getParser()->parse($string);

        if ($this->trimArrayValues && is_array($value)) {
            return $this->trimArray($value);
        }

        return $value;
    }
631804
public static function parse($string)
  {
    $attr = [];
    $list = [];

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

    if ( is_array($attr) ){
      $numPairs = count($attr[1]);
      for ($i = 0; $i < $numPairs; $i++){
        $list[$attr[1][$i]] = $attr[2][$i];
      }
    }
    
    return $list;
  }
855601
public function decode($string)
    {
        $i = 0;

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

        return $i;
    }
1201625
public static function fromString($string)
    {
        if (preg_match(self::PATTERN_FROM_STRING, trim($string), $matches)) {
            if (2 === count($matches)) {
                // whole number
                return new self((int) $matches[1]);
            } else {
                // either x y/z or x/y
                if ($matches[2]) {
                    // x y/z
                    $whole = new self((int) $matches[1]);

                    return $whole->add(new self(
                        (int) $matches[2],
                        (int) $matches[3]
                    ));
                }

                // x/y
                return new self((int) $matches[1], (int) $matches[3]);
            }
        }

        throw new InvalidArgumentException(sprintf(
            'Cannot parse "%s"',
            $string
        ));
    }
1185382
public static function split($pattern, $string, $limit = -1, $flags = 0)
    {
        $offset_capture = (bool)($flags & PREG_SPLIT_OFFSET_CAPTURE);

        $lengths = self::getSplitLengths($pattern, $string);

        // Substrings
        $parts = [];
        $position = 0;
        $count = 1;
        foreach ($lengths as $length) {
            if (self::isLastPart($length, $flags, $limit, $count)) {
                $parts[] = self::makePart($string, $position, null, $offset_capture);
                return $parts;
            }

            if (self::isPart($length, $flags)) {
                $parts[] = self::makePart($string, $position, $length[0], $offset_capture);
            }

            $position += $length[0];
        }

        return $parts;
    }
105475
static function split($string, $token) {
        $array = [];
        
        $tok = strtok($string, $token);
        
        while ($tok != false) {
            array_push($array, $tok);
            
            $tok = strtok($token);
        }
        
        return $array;
    }
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;
    }
1271867
protected function parseNumberTags(string $string): string
	{
		return preg_replace_callback('/\<number(:([0-9]+)(,(.)(,(.))?)?)?\>([0-9-.e]*)\<\/number\>/iu', function($matches)
		{
			return $this->number((float) $matches[7], ($matches[2] ?: 0), $matches[4], $matches[6]);
		}, $string);
	}
183094
private static function mbStringToArray($string)
    {
        $stop   = mb_strlen($string, 'utf-8');
        $result = array();

        for ($idx = 0; $idx < $stop; $idx++) {
            $result[] = mb_substr($string, $idx, 1, 'utf-8');
        }

        return $result;
    }
636221
public static function stringSplit($string, $chunkLength=0, $charset='UTF-8')
    {

        if ($chunkLength < 1) {
            return preg_split("//u", $string, -1, PREG_SPLIT_NO_EMPTY);
        }


        $split = [];

        $len = mb_strlen($string, $charset);

        for ($i = 0; $i < $len; $i += $chunkLength) {
            $split[] = mb_substr($string, $i, $chunkLength, $charset);
        }

        return $split;

    }
831360
static function extractNumerics($string, array $include = []) {
    // Make sure it's string
    $string = (string) $string;
    // Set numerics
    $numerics = '';
    // Get length
    $len = strlen($string);
    // Loop through string
    for ($i = 0; $i < $len; $i++) {
      // If digit
      if (static::isDigit($string[$i])) {
        // Append to numerics
        $numerics .= $string[$i];
      }
      // If decimal
      if ($include && in_array($string[$i], $include)) {
        // Append to numerics
        $numerics .= $string[$i];
      }
    }
    // Return numerics
    return $numerics;
  }