Strip suffix.

@param string $data
@param string $prefix
@param string $separator Default ''.
@return string
187314
public static function stripSuffix(string $data, string $prefix, string $separator = ''): string
    {
        if ($data === '') {
            return $data;
        }
        if ($separator !== '') {
            $data = rtrim($data, $separator);
        }
        if (static::substr($data, -static::length($prefix)) === $prefix) {
            $data = static::substr($data, 0, -static::length($prefix));
        }
        if ($separator !== '') {
            $data = rtrim($data, $separator);
        }
        return $data;
    }
830082
private function tokenize($string, $separator = '')
    {
        if (!strcmp($separator, '')) {
            $separator = $string;
            $string = $this->headerNextToken;
        }

        for ($character = 0; $character < strlen($separator); $character++) {
            if (gettype($position = strpos($string, $separator[$character])) == 'integer') {
                $found = (isset($found) ? min($found, $position) : $position);
            }
        }

        if (isset($found)) {
            $this->headerNextToken = substr($string, $found + 1);

            return substr($string, 0, $found);
        } else {
            $this->headerNextToken = '';

            return $string;
        }
    }
400461
public static function removePrefix($string, $prefix)
    {
        if (self::startsWith($string, $prefix)) {
            return substr($string, mb_strlen($prefix));
        }
        return $string;
    }
668161
public static function wrap(string $text, int $length, string $separator = "\n"): string
    {
        if ($text === '' || self::length($text) === $length) {
            return $text;
        }
        $endedWithLinebreak = substr($text, -1) === "\n";
        $text = str_replace("\r", '', $text);
        $text = str_replace("\n", '', $text);
        $text = explode(' ', $text);

        $result = [];
        $lineNo = 0;
        foreach ($text as $word) {
            if (!isset($result[$lineNo])) {
                $result[$lineNo] = '';
            }
            $lastLineNo = count($result) - 1;

            if ((self::length($result[$lastLineNo]) + self::length($word)) >= $length) {
                $lineNo++;
                if (!isset($result[$lineNo])) {
                    $result[$lineNo] = '';
                }
                $lastLineNo = count($result) - 1;
            }

            $result[$lastLineNo] .= $result[$lastLineNo] !== '' ? ' ' : '';
            $result[$lastLineNo] .= $word;
        }

        $text = implode($separator, $result);
        if ($endedWithLinebreak) {
            $text .= "\n";
        }
        return $text;
    }
886605
public static function getLastElementOfString($string, $separator)
    {
        $elements = self::getStringElements($string, $separator);

        /*
         * No elements?
         * Nothing to do
         */
        if (empty($elements)) {
            return null;
        }

        $element = Arrays::getLastElement($elements);

        return trim($element);
    }
798054
def extract_separator
      if meta_tags[:separator] == false
        # Special case: if separator is hidden, do not display suffix/prefix
        prefix = separator = suffix = ''
      else
        prefix    = extract_separator_section(:prefix, ' ')
        separator = extract_separator_section(:separator, '|')
        suffix    = extract_separator_section(:suffix, ' ')
      end
      delete(:separator, :prefix, :suffix)

      TextNormalizer.safe_join([prefix, separator, suffix], '')
    end
445977
protected function flattenData(array $data, $prefix = '', $format = '%s')
    {
        $flat = array();

        foreach ($data as $name => $value) {

            $ref = $prefix . sprintf($format, $name);

            if (is_array($value)) {

                $flat += $this->flattenData($value, $ref, '[%s]');
                continue;
            }

            $flat[$ref] = $value;
        }

        return $flat;
    }
320695
public static function flatten($array, $separator = '.', $prefix = '')
	{
		$return = array();

		if ($array instanceof \Traversable)
		{
			$array = iterator_to_array($array);
		}
		elseif (is_object($array))
		{
			$array = get_object_vars($array);
		}

		foreach ($array as $k => $v)
		{
			$key = $prefix ? $prefix . $separator . $k : $k;

			if (is_object($v) || is_array($v))
			{
				$return = array_merge($return, static::flatten($v, $separator, $key));
			}
			else
			{
				$return[$key] = $v;
			}
		}

		return $return;
	}
1242039
public static function forcePrefix(string $data, string $prefix, string $separator = ''): string
    {
        if ($data === '') {
            return $data;
        }
        if ($separator !== '') {
            $data = trim($data, $separator);
        }
        if (static::substr($data, 0, static::length($prefix)) !== $prefix) {
            if ($separator !== '') {
                $prefix .= $separator;
            }
            $data = $prefix . $data;
        }
        return $data;
    }
1355323
public static function urlizeTrim($text, $separator = '-')
    {
        return trim(self::urlize(UtilString::toSlugg($text), $separator), $separator);
    }
208480
def strip_suffix(string, suffix):
    """"""
    if string.endswith(suffix):
        return string[:-(len(suffix))]
    return string
1148841
public static function prettyPrint($data, $prefix = '')
    {
        $php = '[' . PHP_EOL;
        if (is_array($data) and array_diff_key($data, array_keys(array_keys($data)))) {
            foreach ($data as $key => $value) {
                $php .= $prefix . '  ' . var_export($key, true) . ' => ';
                if (is_array($value)) {
                    $php .= self::prettyPrint($value, $prefix . '  ');
                } else {
                    $php .= var_export($value, true);
                }
                $php .= ',' . PHP_EOL;
            }
        } else {
            foreach ($data as $value) {
                $php .= $prefix . '  ';
                if (is_array($value)) {
                    $php .= self::prettyPrint($value, $prefix . '  ');
                } else {
                    $php .= var_export($value, true);
                }
                $php .= ',' . PHP_EOL;
            }
        }
        return $php . $prefix . ']';
    }
453487
public static function stripPrefix($table, $prefix = null)
    {
        $prefix = $prefix ?: Ioc::getDatabase()->getPrefix();

        $num = strlen($prefix);

        if (substr($table, 0, $num) == $prefix) {
            $table = '#__' . substr($table, $num);
        }

        return $table;
    }
91384
function stripHTTPHeader( $data )
    {
        $start = strpos( $data, "<?xml version=\"1.0\"?>" );
        return substr( $data, $start, strlen( $data ) - $start );
    }
800896
public function prefix( $prefix )
    {
        // Detect the Regexp delimiter
        $patternDelim = $this->pattern[0];

        // Add the Regexp delimiter to the prefix
        $prefix = $patternDelim . $prefix . $patternDelim;
        parent::prefix( $prefix );
    }
469974
public function isDot(string $notation, string $separator = '.'): bool
    {
        $args = explode($separator, $notation);

        if (count($args) == 0) {
            return false;
        }

        $last = array_pop($args);

        $pointer = &$this->data;
        foreach ($args as $i => $step) {
            if (!isset($pointer[$step])
                || !is_array($pointer[$step])
            ) {
                return false;
            }

            $pointer = &$pointer[$step];
        }

        if (!isset($pointer[$last])) {
            return false;
        }

        return true;
    }
122597
function split(separator, data, limit) {
	var data = ""+data,
	    results = data.split(separator);
	if(!limit) return results;
	if(results.length <= limit) return results;
	var separators = data.match(new RegExp(separator.source, "g"));
	results[limit-1] = join(results.slice(limit-1), separators.slice(limit-1));
	results.length = limit;
	return results;
}