Convert a string to snake case.

@param string $str
@param string $delimiter
@return string
762671
public static function convertSnake($str, $delimiter = '_')
	{
		if (ctype_lower($str)) return $str;

		return strtolower(preg_replace('/(.)(?=[A-Z])/', '$1' . $delimiter, $str));
	}
515809
function snake( string $delimiter = '_' ) : SplString
    {
        $string = $this->__toString();
        if( !ctype_lower( $string ) ){
            $string = preg_replace( '/\s+/u', '', ucwords( $this->__toString() ) );
            $string = $this->setString( preg_replace( '/(.)(?=[A-Z])/u', '$1'.$delimiter, $string ) );
            $this->setString( $string );
            $this->lower();
        }
        return $this;
    }
597347
private static function parseString($str)
    {
        if ($str[0] !== '"' || $str[strlen($str) - 1] !== '"') {
            throw new Exception("Invalid string delimiters");
        }

        $result = '';
        $start = str_split(substr($str, 1, -1), 1);
        $escaped = false;
        $data = null;

        foreach ($start as $chr) {
            if ($escaped === 'yes') {
                $escaped = false;
                switch ($chr) {
                    case 'n':  $result .= "\n"; break;
                    case 'r':  $result .= "\r"; break;
                    case 't':  $result .= "\t"; break;
                    case 'v':  $result .= "\v"; break;
                    case 'e':  $result .= "\e"; break;
                    case 'f':  $result .= "\f"; break;
                    case '\\': $result .= "\\"; break;
                    case '$':  $result .= "\$"; break;
                    case '"':  $result .= "\""; break;
                    case 'x':
                        $escaped = 'hex';
                        $data = '0x';
                        break;
                    default:
                        if (ctype_digit($chr) && (int)$chr < 8) {
                            $escaped = 'oct';
                            $data = $chr;
                        } else {
                            $result .= "\\" . $chr;
                        }
                        break;
                }
            } else if ($escaped === 'hex' && ctype_xdigit($chr)) {
                $data .= $chr;
                if (strlen($data) === 2) {
                    $escaped = false;
                }
            } else if ($escaped === 'oct' && ctype_digit($chr) && (int)$chr < 8) {
                $data .= $chr;
                if (strlen($data) === 3) {
                    $escaped = false;
                }
            } else {
                if ($data !== null || $escaped === 'hex' || $escaped === 'oct') {
                    if (substr($data, 0, 2) === '0x') {
                        if (strlen($data) === 2) {
                            $result .= "\\x";
                        } else {
                            $result .= chr(hexdec($data));
                        }
                    } else {
                        $result .= chr(octdec($data));
                    }
                    $data = null;
                }

                if ($chr === '\\') {
                    $escaped = 'yes';
                } else if ($chr === '"') {
                    throw new Exception("Unescaped string delimiter inside string");
                } else {
                    $result .= $chr;
                }
            }
        }
        if ($escaped !== false) {
            throw new Exception("Unfinished escape sequence");
        }
        return $result;
    }
796493
public static function toCamelCase($str)
    {
        $str = ucwords(str_replace('_', ' ', $str));
        $str = str_replace(' ', '', lcfirst($str));
        return $str;
    }
1309168
public function parsePasswordOTP($str, $delim = '[:]')
    {
        if (!preg_match("/^((.*)" . $delim . ")?(([cbdefghijklnrtuvCBDEFGHIJKLNRTUV]{0,16})([cbdefghijklnrtuvCBDEFGHIJKLNRTUV]{32}))$/", $str, $matches)) {
            /* Dvorak? */
            if (!preg_match("/^((.*)" . $delim . ")?(([jxe.uidchtnbpygkJXE.UIDCHTNBPYGK]{0,16})([jxe.uidchtnbpygkJXE.UIDCHTNBPYGK]{32}))$/", $str, $matches)) {
                return false;
            } else {
                $ret['otp'] = strtr($matches[3], "jxe.uidchtnbpygk", "cbdefghijklnrtuv");
            }
        } else {
            $ret['otp'] = $matches[3];
        }

        $ret['password'] = $matches[2];
        $ret['prefix'] = $matches[4];
        $ret['ciphertext'] = $matches[5];

        return $ret;
    }
716033
public static final List<DelimiterInfo> extractDelimiterList(final String str, final String delimiter) {
        assertStringNotNull(str);
        assertDelimiterNotNull(delimiter);
        final List<DelimiterInfo> delimiterList = new ArrayList<DelimiterInfo>();
        DelimiterInfo previous = null;
        String rear = str;
        while (true) {
            final int beginIndex = rear.indexOf(delimiter);
            if (beginIndex < 0) {
                break;
            }
            final DelimiterInfo info = new DelimiterInfo();
            info.setBaseString(str);
            info.setDelimiter(delimiter);
            final int absoluteIndex = (previous != null ? previous.getEndIndex() : 0) + beginIndex;
            info.setBeginIndex(absoluteIndex);
            info.setEndIndex(absoluteIndex + delimiter.length());
            if (previous != null) {
                info.setPrevious(previous);
                previous.setNext(info);
            }
            delimiterList.add(info);
            previous = info;
            rear = str.substring(info.getEndIndex());
            continue;
        }
        return delimiterList;
    }
943689
function camelCase(str, delim) {
        var delims = delim || ['_', '.', '-'];

        if (!_.isArray(delims)) {
            delims = [delims];
        }

        _.each(delims, function (adelim) {
            var codeParts = str.split(adelim);
            var i, codePart;

            for (i = 1; i < codeParts.length; i++) {
                codePart = codeParts[i];
                codeParts[i] = codePart.substring(0, 1).toUpperCase() + codePart.substring(1);
            }

            str = codeParts.join('');
        });

        return str;
    }
1231758
public static function explodeTrim($str, $delimiter = ',')
    {
        if (is_string($delimiter)) {
            $str = trim(preg_replace('|\\s*(?:' . preg_quote($delimiter) . ')\\s*|', $delimiter, $str));
            return explode($delimiter, $str);
        }
        return $str;
    }
752850
public static function split(string $string, string $delimiter = ','): array
    {
        return preg_split('/\s*' . preg_quote($delimiter, '/') . '\s*/', $string, -1, PREG_SPLIT_NO_EMPTY);
    }
496277
public function implode(string $delimiter) : string
    {
        return rtrim($this->fold(function (string $fold, $elem) use ($delimiter) {
            $fold .= A\concat($delimiter, $elem, '');
            return $fold;
        }, '')->getList(), $delimiter);
    }
1087013
public function snakeCase($value, $delimiter = '_')
    {
        if (!ctype_lower($value)) {
            $value = strtolower(preg_replace('/(.)(?=[A-Z])/', '$1'.$delimiter, $value));
            $value = preg_replace('/\s+/', '', $value);
        }

        return $value;
    }
428636
public function Explode($delimiter)
    {
        if (!$delimiter || !$string = $this->owner->value) {
            return;
        }
        $values = ArrayList::create();
        foreach (explode($delimiter, $string) as $value) {
            $values->push(
                ArrayData::create(['Value' => $value])
            );
        }
        return $values;
    }
545181
public function str(string $delimiter): self
    {
        $sub = \mb_strstr($this->value, $delimiter, false, (string) $this->encoding());

        if ($sub === false) {
            throw new SubstringException(\sprintf(
                'Substring "%s" not found',
                $delimiter
            ));
        }

        return new self($sub, $this->encoding);
    }
1102773
public function toString($delimiter = ',')
    {
        $result = [];
        array_walk_recursive($this->attributes, function($v) use (&$result) {
            $result[] = $v;
        });

        return \implode($delimiter, $result);
    }
467382
public function split(string $delimiter = null): StreamInterface
    {
        if (\is_null($delimiter) || $delimiter === '') {
            return $this->chunk();
        }

        $parts = \explode($delimiter, $this->value);
        $stream = new Stream(self::class);

        foreach ($parts as $part) {
            $stream = $stream->add(new self($part, $this->encoding));
        }

        return $stream;
    }
1042862
public static function toSnakeCase($str, $sep = '_')
    {
        // 'CMSCategories' => 'cms_categories'
        // 'RangePrice' => 'range_price'
        return self::strtolower(trim(preg_replace('/([A-Z][a-z])/', $sep . '$1', $str), $sep));
    }
423247
function(str) {
      var SNAKE_CASE_REGEXP = /[A-Z]/g;
      return str.replace(SNAKE_CASE_REGEXP, function(letter, pos) {
        return (pos ? '-' : '') + letter.toLowerCase();
      });
    }