Takes a string that represents for example a class name and returns
    the snake case version of it. It is used for model-to-key conversion
167887
def snake_case(string):
    '''  '''
    s1 = re.sub('(.)([A-Z][a-z]+)', r'\1_\2', string)

    return re.sub('([a-z0-9])([A-Z])', r'\1_\2', s1).lower()
28015
public function toSnakeCase()
    {
        $snake = UTF8::normalize_whitespace($this->scalarString);

        $snake = str_replace('-', '_', $snake);

        $snake = preg_replace_callback
        (
            '/([\d|A-Z])/u',
            function ($matches)
            {
                $match = $matches[1];
                $matchInt = (int)$match;

                if ("$matchInt" == $match)
                {
                    return '_' . $match . '_';
                }
                else
                {
                    return '_' . UTF8::strtolower($match, $this->encoding);
                }
            },
            $snake
        );

        $snake = preg_replace
        (
            [
                '/\s+/',        // convert spaces to "_"
                '/^\s+|\s+$/',  // trim leading & trailing spaces
                '/_+/'          // remove double "_"
            ],
            [
                '_',
                '',
                '_'
            ],
            $snake
        );

        // trim leading & trailing "_"
        $snake = UTF8::trim($snake, '_');

        // trim leading & trailing whitespace
        $snake = UTF8::trim($snake);

        return $this->newSelf($snake);
    }
625751
def apply(cls, text, mode):
        
        if mode == cls.SCREAMING_SNAKE_CASE:
            return cls._screaming_snake_case(text)
        elif mode == cls.snake_case:
            return cls._snake_case(text)
        elif mode == cls.lowercase:
            return cls._snake_case(text).replace('_', '')
        elif mode == cls.lowerCamelCase:
            return cls._camel_case(text)
        elif mode == cls.CamelCase:
            return cls._camel_case(text, True)
        elif callable(mode):
            return mode(text)
        return text
1276490
def to_snake_case(name):
    
    s1 = first_cap_re.sub(r'\1_\2', name)
    # handle acronym words
    return all_cap_re.sub(r'\1_\2', s1).lower()
638109
def camel_to_snake_case(string):
    
    s = _1.sub(r'\1_\2', string)
    return _2.sub(r'\1_\2', s).lower()
130229
def _to_camelcase(input_string):
    ''' '''
    camel_string = ''
    for i in range(len(input_string)):
        if input_string[i] == '_':
            pass
        elif not camel_string:
            camel_string += input_string[i].upper()
        elif input_string[i-1] == '_':
            camel_string += input_string[i].upper()
        else:
            camel_string += input_string[i]
    return camel_string
668640
def kebab_case(string):
    
    if not string:
        return string
    string = string.replace('_', '-').replace(' ', '-')
    return de_camel(string, '-')
729433
def class_case(string):
    
    if not string:
        return string
    string = string.replace(' ', '_').replace('-', '_')
    parts = de_camel(string, '_', _lowercase=False).split('_')
    rv = ''
    while parts:
        part = parts.pop(0)
        rv += part.title() or '_'
        if part:
            break
    return rv + ''.join([part if part.isupper() else part.title()
                         for part in parts])
3642
@Override
	public String getString(final String columnLabel) throws SQLException {
		String val = getWrapped().getString(columnLabel);
		if (this.cryptColumnNames.contains(CaseFormat.UPPER_SNAKE_CASE.convert(columnLabel))) {
			return decode.apply(val);
		} else {
			return val;
		}
	}
753356
def _snake_to_camel_case(value):
    """"""
    words = value.split("_")
    return words[0] + "".join(map(str.capitalize, words[1:]))
968800
static String nameConvert(String name, boolean mapCamelCaseToUnderscore) {
    if (!mapCamelCaseToUnderscore)
      return name;
    StringBuilder sbd = new StringBuilder();
    char prevChar = name.charAt(0);
    sbd.append(Character.toLowerCase(prevChar));
    for (int i = 1, len = name.length(); i < len; i++) {
      char c = name.charAt(i);
      if (Character.isUpperCase(c)) {
        int next = i + 1;
        char nextChar = (next < len) ? name.charAt(next) : '\0';
        if (Character.isLowerCase(prevChar) || Character.isLowerCase(nextChar)) {
          sbd.append('_');
        }
        sbd.append(Character.toLowerCase(c));
      } else {
        sbd.append(c);
      }
      prevChar = c;
    }
    return sbd.toString();
  }
350722
def camel_case(snake_str):
    

    components = snake_str.split('_')
    # We capitalize the first letter of each component except the first one
    # with the 'title' method and join them together.
    return components[0] + "".join(x.title() for x in components[1:])
640366
public static String to(String str, NamingStyle namingStyle) {
        NamingStyle ns = namingStyle;
        if (str == null) {
            return null;
        }
        if (ns == null) {
            ns = NamingStyle.CAMEL;
        }
        String formatStr;
        switch (ns) {
        case CAMEL:
            formatStr = toLowerCamel(str);
            break;
        case SNAKE:
            formatStr = toSnake(str);
            break;
        case PASCAL:
            formatStr = toPascal(str);
            break;
        case KEBAB:
            formatStr = toKebab(str);
            break;
        default:
            formatStr = toLowerCamel(str);
            break;
        }
        return formatStr;
    }
648325
def controller_name(cls, _remove_suffixes=None) -> str:
    
    name = cls if isinstance(cls, str) else cls.__name__
    remove_suffixes = _remove_suffixes or getattr(cls, REMOVE_SUFFIXES_ATTR)
    for suffix in remove_suffixes:
        if name.endswith(suffix):
            name = right_replace(name, suffix, '')
            break
    return snake_case(name)
1356511
function snakeToCamel( string ) {
	return string.replace( ptnSnake, ( all, predecessor, match ) => predecessor + match.toLocaleUpperCase() );
}
159506
def get_class(class_string):
    
    split_string = class_string.encode('ascii').split('.')
    import_path = '.'.join(split_string[:-1])
    class_name = split_string[-1]

    if class_name:
        try:
            if import_path:
                mod = __import__(import_path, globals(), {}, [class_name])
                cls = getattr(mod, class_name)
            else:
                cls = __import__(class_name, globals(), {})
            if cls:
                return cls
        except (ImportError, AttributeError):
            pass

    return None
996885
def snake_case(a_string):
    

    partial = re.sub('(.)([A-Z][a-z]+)', r'\1_\2', a_string)
    return re.sub('([a-z0-9])([A-Z])', r'\1_\2', partial).lower()