Returns a CamelCase string as a snake_case string.
161064
def to_snake_case(camel_case):
  """"""
  if not re.match(r"^[A-Za-z_]\w*$", camel_case):
    raise ValueError(
        "Input string %s is not a valid Python identifier." % camel_case)

  # Add underscore at word start and ends.
  underscored = re.sub(r"([A-Z][a-z])", r"_\1", camel_case)
  underscored = re.sub(r"([a-z])([A-Z])", r"\1_\2", underscored)
  # Add underscore before alphanumeric chunks.
  underscored = re.sub(r"([a-z])([0-9][^_]*)", r"\1_\2", underscored)
  # Remove any underscores at start or end of name and convert to lowercase.
  return underscored.strip("_").lower()
836878
def camel_case(self, snake_case):
        
        components = snake_case.split('_')
        return components[0] + "".join(x.title() for x in components[1:])
1360242
def to_snake_case(name):
    
    s1 = FIRST_CAP_REGEX.sub(r'\1_\2', name)
    return ALL_CAP_REGEX.sub(r'\1_\2', s1).lower()
1356511
function snakeToCamel( string ) {
	return string.replace( ptnSnake, ( all, predecessor, match ) => predecessor + match.toLocaleUpperCase() );
}
889218
def camel_case_from_underscores(string):
    """"""

    components = string.split('_')
    string = ''

    for component in components:
        if component in abbreviations:
            string += component
        else:
            string += component[0].upper() + component[1:].lower()

    return string
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
54995
def snakecase(string)
      string.to_s.gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2')
            .gsub(/([a-z\d])([A-Z])/, '\1_\2')
            .tr("-", "_")
            .gsub(/\s/, "_")
            .gsub(/__+/, "_")
            .downcase
    end
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()
1052244
def __camel_case(word):
        
        word = word.lower()
        if '_' in word:
            split_word = word.split('_')
        else:
            split_word = word.split()
        if len(split_word) > 0:
            for i, word in enumerate(split_word):
                if i > 0:
                    split_word[i] = word.title()
        strings = ''.join(split_word)
        return strings
862098
function snake_case(name){
    var regexp = /[A-Z]/g;
    var separator = '-';
    return name.replace(regexp, function(letter, pos) {
      return (pos ? separator : '') + letter.toLowerCase();
    });
  }
93184
def camel_to_snake(camel):
    """"""
    ret = []
    last_lower = False
    for char in camel:
        current_upper = char.upper() == char
        if current_upper and last_lower:
            ret.append("_")
            ret.append(char.lower())
        else:
            ret.append(char.lower())
        last_lower = not current_upper
    return "".join(ret)
1284021
public static String snakeToCamel(String snake, boolean upper) {
        StringBuilder sb = new StringBuilder();
        boolean firstWord = true;
        for (String word : snake.split("_")) {
            if (!word.isEmpty()) {
                if (firstWord && !upper) {
                    sb.append(word.toLowerCase());
                } else {
                    sb.append(Character.toUpperCase(word.charAt(0))).append(word.substring(1).toLowerCase());
                }
                firstWord = false;
            }
        }
        return sb.toString();
    }
492655
def camel_to_snake_case(name):
    """"""
    pattern = r'[A-Z][a-z]+|[A-Z]+(?![a-z])'
    return '_'.join(map(str.lower, re.findall(pattern, name)))
931919
function snakeCase (str) {
  return str
    .replace(/([a-z])([A-Z])/g, match => match[0] + '_' + match[1])
    .replace(invalidChars, '_')
    .toLowerCase()
}
999232
def camel_to_snake(name):
    
    s1 = FIRST_CAP_RE.sub(r'\1_\2', name)
    return ALL_CAP_RE.sub(r'\1_\2', s1).lower()
643744
def snake_case_backend_name(self):
        
        s1 = re.sub('(.)([A-Z][a-z]+)', r'\1_\2', type(self).__name__)
        return re.sub('([a-z0-9])([A-Z])', r'\1_\2', s1).lower()
775782
def snake_case_to_headless_camel_case(snake_string):
  
  return ''.join([snake_string.split('_')[0]] +
                 list(sub_string.capitalize()
                      for sub_string in snake_string.split('_')[1:]))