Composite data element

@param string $str

@return mixed
346350
private function splitData(string &$str)
    {
        if ($str === '') {
            return $str;
        }

        $replace = function (&$string) {

            if (\strpos($string, $this->symbUnescapedRel) !== false) {
                $string = \preg_replace(
                    self::$DELIMITER . $this->symbRel . "(?=" . $this->symbRel . ")|" . $this->symbRel . "(?=" . $this->sepData . ")|" . $this->symbRel . "(?=" . $this->sepComp . ")|" . $this->symbRel . "(?=" . $this->symbEnd . ")" . self::$DELIMITER,
                    '',
                    $string
                );
            }

            return \str_replace(
                $this->stringSafe,
                $this->symbUnescapedRel,
                $string
            );
        };

        // check for "sepUnescapedComp" in the string
        if (\strpos($str, $this->sepUnescapedComp) === false) {
            return $replace($str);
        }

        // split on "sepComp" if not escaped (negative lookbehind)
        $array = \preg_split(
            self::$DELIMITER . "(?<!" . $this->symbRel . ")" . $this->sepComp . self::$DELIMITER,
            $str
        );
        // fallback
        if ($array === false) {
            $array = [[]];
        }

        if (\count($array) === 1) {
            return $replace($str);
        }

        foreach ($array as &$value) {
            $value = $replace($value);
        }

        return $array;
    }
488038
public static function minify($str)
    {
        $matchesCode = $matchesPre  = $matches     = [];

        preg_match_all('/<code.*?>(.*?)<\/code>/mis', $str, $matchesCode);
        preg_match_all('/<pre.*?>(.*?)<\/pre>/mis', $str, $matchesPre);
        $matches = array_merge($matchesCode[1], $matchesPre[1]);
        foreach ($matches as $match) {
            $str = str_replace($match, '$'.md5($match), $str);
        }
        $str = preg_replace(['/<!--(.*)-->/Uis', "/[[:blank:]]+/"], ['', ' '],
            str_replace(["\n", "\r", "\t"], '', $str));
        foreach ($matches as $match) {
            $str = str_replace('$'.md5($match), $match, $str);
        }
        return $str;
    }
264573
function parse($str) {
		preg_match_all('/(\w+|\*)\h*=\h*(?:\[(.+?)\]|(.+?))(?=,|$)/',
			$str,$pairs,PREG_SET_ORDER);
		$out=[];
		foreach ($pairs as $pair)
			if ($pair[2]) {
				$out[$pair[1]]=[];
				foreach (explode(',',$pair[2]) as $val)
					array_push($out[$pair[1]],$val);
			}
			else
				$out[$pair[1]]=trim($pair[3]);
		return $out;
	}
692261
private function doUnserialize($str)
    {
        $m = $this->allowedClasses ? @unserialize($str, [
            'allowed_classes' => $this->allowedClasses,
        ]) : @unserialize($str);

        if (false === $m) {
            $err = error_get_last();
            throw new SerializationError(sprintf(
                'Error unserializing message: %s', 
                $err && isset($err['message']) ? $err['message'] : 'unknown error'
            ));
        }

        return $m;
    }
1368736
protected static function getParts($str) {
        $reg = '/^(\d{2}){0,1}(\d{2})(\d{2})(\d{2})([\+\-\s]?)(\d{3})(\d)$/';
        preg_match($reg, $str, $match);

        if (!isset($match) || count($match) !== 8) {
            return array();
        }

        $century = $match[1];
        $year    = $match[2];
        $month   = $match[3];
        $day     = $match[4];
        $sep     = $match[5];
        $num     = $match[6];
        $check   = $match[7];

        if (!in_array($sep, array('-', '+'))) {
            if (empty($century) || date('Y') - intval(strval($century) . strval($year)) < 100) {
                $sep = '-';
            } else {
                $sep = '+';
            }
        }

        if (empty($century)) {
            if ($sep === '+') {
                $baseYear = date('Y', strtotime('-100 years'));
            } else {
                $baseYear = date('Y');
            }
            $century = substr(($baseYear - (($baseYear - $year) % 100)), 0, 2);
        }

        return array(
            'century' => $century,
            'year' => $year,
            'month' => $month,
            'day' => $day,
            'sep' => $sep,
            'num' => $num,
            'check' => $check
        );
    }
678550
public static function getBasic($str)
    {
        $r = '';
        /*
         * Split the string by line breakes.
         */
        foreach (preg_split('/\n\r|\n|\r/', $str, -1, PREG_SPLIT_NO_EMPTY) as $k => $line) {
            /*
             * And append it with tabs and line breaks to the return var.
             */
            $r .= Generator::getTabs();
            $r .= trim($line);
            $r .= Generator::getLineBreak();
        }

        return $r;
    }
1007430
public static function parse($str)
    {
        $bLength = 0;
        if ('b' === $str[0]) {
            $bLength = 1;
        }

        if ('\'' === $str[$bLength]) {
            return str_replace(
                ['\\\\', '\\\''],
                ['\\', '\''],
                substr($str, $bLength + 1, -1)
            );
        } else {
            return self::parseEscapeSequences(substr($str, $bLength + 1, -1), '"');
        }
    }
534799
public static function getGender($str) {

    if (empty($str)) {
      return 'N';
    }

    # Convert to simplified
    $str = ChineseMaster::trad2simp($str);

    $chars = preg_split('//u', $str, -1, PREG_SPLIT_NO_EMPTY); # array
    $count = count($chars);
    $sum   = 0;

    foreach ($chars as $char) {
      if (array_key_exists($char, self::$dict)) {
        $sum += self::$dict[$char];
      }
      else {
        $sum += .5;
      }
    }

    $score = round($sum/$count, 2) - 0.5;

    if ($score > 0.04) {
      return 'M';
    }

    if ($score < -0.04) {
      return 'F';
    }

    return 'N'; # Neutral
  }
513746
protected static function ourStrlen($str)
    {
        // Premature optimization: cache the function_exists() result
        static $exists = null;
        if ($exists === null) {
            $exists = \function_exists('\\mb_strlen');
        }

        // If it exists, we need to make sure we're using 8bit mode
        if ($exists) {
            return \mb_strlen($str, '8bit');
        }
        return \strlen($str);
    }
828492
public static function getString(&$str)
    {
        $p = mb_orig_strpos($str, "\x00");
        if ($p === false) {
            return '';
        }
        $r = mb_orig_substr($str, 0, $p);
        $str = mb_orig_substr($str, $p + 1);
        return $r;
    }
532941
public function fromBin(string $str):string {
		$this->checkLength($str);
		$this->checkBin($str);

		// Base32 works on the first 5 bits of a byte, so we insert blanks to pad it out
		$str = preg_replace('/(.{5})/', '000$1', $str);

		// We need a string divisible by 5
		$length = strlen($str);
		$rbits = $length&7;

		if($rbits > 0){
			// Excessive bits need to be padded
			$ebits = substr($str, $length-$rbits);
			$str = substr($str, 0, $length-$rbits).'000'.$ebits.str_repeat('0', 5-strlen($ebits));
		}

		preg_match_all('/.{8}/', $str, $chrs);

		$chrs = array_map(function($str){
			return $this->charset[bindec($str)];
		}, $chrs[0]);

		return implode('', $chrs);
	}
170971
public static function get(string $str):array
    {
        $str = trim($str);
        $strArr = Str::toArray($str);
        $results = [];
        foreach ($strArr as $s) {
            $results[] = self::getSingle($s);
        }
        return $results;
    }
878266
public function searchAndReplace($str)
	{
		$this->matcher->load($str, $this->collection);

		return $this->matcher->searchAndReplace();
	}
668183
private function append_str($str)
  { 
    $this->check_closed(); 
    $this->string_buffer .= $str; 
    $len = strlen($str); 
    $this->current_index += $len; 
    return $len; 
  }
1185327
protected static function exportString($str)
	{
		// foo becomes 'foo'
		if (strpos($str, "'") === false)
		{
			return "'" . $str . "'";
		}

		// d'oh becomes "d'oh"
		if (strpos($str, '"') === false)
		{
			return '"' . $str . '"';
		}

		// This string contains both ' and ". XPath 1.0 doesn't have a mechanism to escape quotes,
		// so we have to get creative and use concat() to join chunks in single quotes and chunks
		// in double quotes
		$toks = [];
		$c    = '"';
		$pos  = 0;
		while ($pos < strlen($str))
		{
			$spn = strcspn($str, $c, $pos);
			if ($spn)
			{
				$toks[] = $c . substr($str, $pos, $spn) . $c;
				$pos   += $spn;
			}
			$c = ($c === '"') ? "'" : '"';
		}

		return 'concat(' . implode(',', $toks) . ')';
	}
369868
public function parse($str)
    {
        $this->removeBom($str);

        $data = $this->createM3uData();
        $lines = \explode("\n", $str);

        for ($i = 0, $l = \count($lines); $i < $l; ++$i) {
            $lineStr = \trim($lines[$i]);
            if ('' === $lineStr || $this->isComment($lineStr)) {
                continue;
            }

            if ($this->isExtM3u($lineStr)) {
                $tmp = \trim(\substr($lineStr, 7));
                if ($tmp) {
                    $data->initAttributes($tmp);
                }
                continue;
            }

            $data->append($this->parseLine($i, $lines));
        }

        return $data;
    }
1140485
public static function getStrong($str)
    {
        /*
         * Split the content by html tags.
         */
        $tree = preg_split(
            '/(<[^!]?[^>]+>(<![^>]+>)?)/',
            $str,
            -1,
            PREG_SPLIT_OFFSET_CAPTURE | PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY
        );

        /*
         * Initiate variables.
         */
        $r = array();
        $line = '';
        $isInline = true;
        $oneLine = array();
        $lastWasTag = false;

        /*
         * Loop throu the tree.
         */
        foreach ($tree as $k => $elm) {
            /*
             * Check what kind of element this is.
             */
            $info;
            switch (self::_getTreeElm($elm[0], $info)) {
            case 'start':
                /*
                 * It's a starting tag
                 */
                $add = new Tag(
                    $info[1], /* The Tags Name */
                    array(self::parseAttrs($info[2])), /* The attributes */
                    array(
                        'generate',
                        ($info[3] == '/>' ? 'selfQlose' : 'doNotSelfQlose'),
                        'start',
                        (in_array($info[1], TagInfo::$inlineTags) ? 'inline' : null)
                    )
                );
                break;
            case 'end':
                /*
                 * It is a closing tag
                 */
                $add = Store::get();
                break;
            case 'comment':
            case 'content':
            default:
                /*
                 * It's something else
                 */
                $add = $elm[0];
                break;
            }

            /*
             * Add the current content to the output.
             */
            self::_toLine($add, $r, $line, $isInline, $oneLine, $lastWasTag);
        }

        /*
         * Check if there is still content in the current line
         * and add it to the return array.
         */
        if (strlen($line)) {
            $r[] = $line;
        }

        /*
         * implode the return array using line breaks and return the string.
         */

        return implode(Generator::getLineBreak(), $r).Generator::getLineBreak();
    }