Increment a string/separated string.

Example: "a-name" becomes "a-name-2", "a-name-3" and so on.

@param string $string
@param string $separator
@return string
330190
public static function incrementSeparated(string $string, string $separator = '-'): string
    {
        if (preg_match('/' . $separator . '(\d+)$/', $string, $matches)) {
            $string = self::stripRight($string, $separator . $matches[1]);
            $duplicateNo = ((int) $matches[1]) + 1;
        } else {
            $duplicateNo = 2;
        }

        $newString = $string . $separator . $duplicateNo;

        return $newString;
    }
1096577
public static function standardize(string $string, string $rules, string $separator = '_'): string
    {
        $string = self::transliterate($string, $rules);
        $string = trim($string);
        $string = strtolower($string);

        return preg_replace(['#[-_\s]+#', '#[^' . $separator . '\w\d]+#i'], [$separator, ''], $string);
    }
84586
public static function slug($string, $separator = '-', array $options = [])
    {
        if (!static::$slugify instanceof Slugify) {
            static::$slugify = Slugify::create($options);
        }

        return mb_strtolower(static::$slugify->slugify($string, $separator));
    }
1355547
public function removeDot(string $notation, string $separator = '.')
    {
        $args = explode($separator, $notation);

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

        $last = array_pop($args);

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

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

        unset($pointer[$last]);

        return $this;
    }
985844
public static function substringBefore($string, $separator)
    {
        $pos = mb_strpos($string, $separator);
        return $pos !== false ? mb_substr($string, 0, $pos) : $string;
    }
693860
public static String substringBefore(final String str, final String separator) {
        if (Strings.isNullOrEmpty(str)) {
            return str;
        }
        final int pos = str.indexOf(separator);
        if (pos == -1) {
            return str;
        }
        return str.substring(0, pos);
    }
1007308
public function substringAfterLast($separator)
    {
        if (($offset = $this->indexOfLast($separator)) === false) {
            return false;
        }

        return static::create(mb_substr($this->str, $offset + mb_strlen($separator, $this->encoding), null, $this->encoding), $this->encoding);
    }
1102962
public function concatenate($values, $separator = null)
  {
    if ( $separator ){
      return 'CONCATENATE(' . implode(' || ' . $this->q($separator) . ' || ', $values) . ')';
    }
    else {
      return 'CONCATENATE(' . implode(' || ', $values) . ')';
    }
  }
201681
public function join(array $array, string $separator = ','): string
    {
        $result = '';

        foreach ($array as $item) {
            if (is_array($item)) {
                $result .= $this->join($item, $separator) . $separator;
            } else {
                $result .= $item . $separator;
            }
        }

        $result = substr($result, 0, 0 - strlen($separator));

        return $result;
    }
515306
public static function last(string $string, string $separator): string
    {
        $string = explode($separator, $string);
        return Arr::last($string);
    }
394264
public static function camelCaseToSeparated($string, $separator = '-', $toLowerCase = true)
    {
        $separated = preg_replace(['/([a-z\d])([A-Z])/', '/([^' . preg_quote($separator) . '])([A-Z][a-z])/'], '$1' . $separator . '$2', $string);
        return $toLowerCase ? strtolower($separated) : $separated;
    }
340868
public function separaString($string, $posicaoInicial, $posicaoFinal = null)
    {
        if ($posicaoFinal == null) {
            return substr($string, $posicaoInicial - 1);
        }

        return substr($string, $posicaoInicial - 1, ($posicaoFinal - 1) * (-1));
    }
216703
public static function suffix( $string, $sep = '-' ) 
	{
		return substr( $string, strrpos( $string, $sep )+strlen( $sep ) );
	}
1286043
public static function part(string $string, string $separator, int $index, string $defaultValue = ''): string
    {
        if ($string !== '') {
            $string = explode($separator, $string);
            if (isset($string[$index])) {
                return $string[$index];
            }
        }
        return $defaultValue;
    }
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);
    }
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);
    }
1042843
@Nonnull
    public static String join(@Nonnull Collection<?> strings, @Nonnull String separator) {
        StringBuilder buf = new StringBuilder();
        boolean first=true;
        for (Object s : strings) {
            if(first)   first=false;
            else        buf.append(separator);
            buf.append(s);
        }
        return buf.toString();
    }