Gets the substring before the last occurrence of a separator.
If no match is found returns false.

@param string $separator

@return string|bool
550531
public function substringBeforeLast($separator)
    {
        if (($offset = $this->indexOfLast($separator)) === false) {
            return false;
        }

        return static::create(mb_substr($this->str, 0, $offset, $this->encoding), $this->encoding);
    }
881878
public function toSlug(string $separator = '-'): Utility
    {
        $string = mb_convert_encoding($this->string, 'UTF-8', $this->encoding);
        $string = preg_replace('/[^\s\p{L}0-9\-' . $separator . ']/u', '', $string);
        $string = htmlentities($string, ENT_QUOTES, 'UTF-8');
        $string = preg_replace('~&([a-z]{1,2})(?:acute|cedil|circ|grave|lig|orn|ring|slash|th|tilde|uml);~i', '$1', $string);
        $string = iconv('utf-8', 'ASCII//TRANSLIT//IGNORE', $string);
        $string = html_entity_decode($string, ENT_QUOTES, 'UTF-8');
        $string = preg_replace('~[^0-9a-z]+~i', $separator, $string);
        $string = trim($string, $separator);
        $string = mb_strtolower($string);

        return new static($string, $this->encoding);
    }
154181
protected function getClasses(string $option, string $separator = ' '): string
    {
        return implode($separator, $this->getOption($option));
    }
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);
    }
535625
public function split($separator)
    {
        $hash = new Hash(explode((string) $separator, (string) $this));

        return $hash->map(
            function ($value) {
                return new String($value);
            }
        );
    }
798843
public function setPathSeparator(string $separator)
    {
        if ($this instanceof ParentNodeDefinitionInterface) {
            if (method_exists($this, 'getChildNodeDefinitions')) {
                foreach ($this->getChildNodeDefinitions() as $child) {
                    $child->setPathSeparator($separator);
                }
            } else {
                @trigger_error('Passing a ParentNodeDefinitionInterface without getChildNodeDefinitions() is deprecated since Symfony 4.1.', E_USER_DEPRECATED);
            }
        }

        $this->pathSeparator = $separator;

        return $this;
    }
1196281
public static function fromString($string, $separator=' '){

        $string = (string)$string;

        if($separator === ''){
            return new StringList(str_split($string),'');
        }

        $prefix = '';
        $suffix = '';
        if($string[0] == $separator){
            $prefix = $separator;
        }
        if($string[strlen($string)-1] == $separator){
            $suffix = $separator;
        }
        $strList = new StringList(explode($separator,trim($string,$separator)),
                                          $separator);
        $strList->prefix = $prefix;
        $strList->suffix = $suffix;
        return $strList;
    }
340868
public function separaString($string, $posicaoInicial, $posicaoFinal = null)
    {
        if ($posicaoFinal == null) {
            return substr($string, $posicaoInicial - 1);
        }

        return substr($string, $posicaoInicial - 1, ($posicaoFinal - 1) * (-1));
    }
146559
public function toSlugUtf8(string $separator = '-'): Utility
    {
        $string = mb_convert_encoding($this->string, 'UTF-8', $this->encoding);
        $string = preg_replace('/[^\s\p{L}0-9\-' . $separator . ']/u', '', $string);
        $string = preg_replace('~&([a-z]{1,2})(?:acute|cedil|circ|grave|lig|orn|ring|slash|th|tilde|uml);~i', '$1', $string);
        $string = preg_replace('/[\s_\-]/', $separator, $string);
        $string = trim($string, $separator);
        $string = mb_strtolower($string, 'utf-8');
        return new static($string, $this->encoding);
    }
51089
private function renderTitleFirst($separator)
    {
        $output   = [];
        $output[] = $this->getTitleOnly();

        if ($this->hasSiteName()) {
            $output[] = $separator;
            $output[] = $this->getSiteName();
        }

        return implode('', $output);
    }
706883
public static function machine($str, $separator = '_')
    {
        $out = strtolower($str);
        $out = preg_replace('/[^a-z0-9' . $separator . ']/', $separator, $out);
        $out = preg_replace('/' . $separator . '{2,}/', $separator, $out);
        $out = preg_replace('/^' . $separator . '/', '', $out);
        $out = preg_replace('/' . $separator . '$/', '', $out);
        return $out;
    }
639374
public function getListeBase($separator)
    {
        $all_coll = $this->getAllColl();
        $liste = '';
        foreach ($all_coll as $sbas => $info) {
            $liste .= phrasea::sbas_labels($sbas, $this->app) . ' ' . $separator . ' ';
        }

        return $liste;
    }
1222067
protected function splitText($part)
    {
        if ($part === 'before' || $part === 'rest')
        {
            $parts = explode(static::separator, $this->text);

            if (count($parts) === 1 && $part === 'rest')
            {
                return null;
            }

            return ($part === 'before') ? current($parts) : end($parts);
        }

        return str_replace(static::separator, '', $this->text);
    }
948387
public static function format($string, $format, $separator = '/')
	{
		// Trim
		$string = trim($string, $separator);
		
		// Empty path case
		if ($string === '') {
			if ($format == self::FORMAT_BOTH_DELIMITERS) {
				return $separator;
			} else {
				return $string;
			}
		}
		
		// Add delimiters
		if ($format & self::FORMAT_LEFT_DELIMITER) {
			$string = $separator . $string;
		}
		if ($format & self::FORMAT_RIGHT_DELIMITER) {
			$string = $string . $separator;
		}
		
		return $string;
	}
317043
public function getSeparator()
    {
        if (!$this->separator && $this->getFilePath()) {
            $this->separator = $this->detector->separator(
                $this->firstLines(),
                $this->getDelimiter()
            );
            $this->separatorWasDetected = true;
        }

        return $this->separator;
    }
1247724
public function slug($separator = '-')
    {
        $str = $this->toAscii();

        $flip = $separator == '-' ? '_' : '-';
        $str = str_replace('.', $separator, $str);
        $str = preg_replace('!['.preg_quote($flip).']+!u', $separator, $str);
        $str = preg_replace('![^'.preg_quote($separator).'\pL\pN\s]+!u', '', mb_strtolower($str));
        $str = preg_replace('!['.preg_quote($separator).'\s]+!u', $separator, $str);

        return trim($str, $separator);
    }
363364
public function getDefinition($separator=',')
	{
		$commands = self::$commands;

		if (sizeof($commands) > 0) {
			return implode($separator, $commands);
		}

		return null;
	}