Transform camel or pascal case to underscore separated string
12568
def to_underscore(s):
    
    return re.sub(
            r'(?!^)([A-Z]+)',
            lambda m: "_{0}".format(m.group(1).lower()),
            re.sub(r'(?!^)([A-Z]{1}[a-z]{1})', lambda m: "_{0}".format(m.group(1).lower()), s)
        ).lower()
606726
def camelcase_underscore(name):
    
    s1 = re.sub('(.)([A-Z][a-z]+)', r'\1_\2', name)
    return re.sub('([a-z0-9])([A-Z])', r'\1_\2', s1).lower()
6635
private static String camelFormat(String str, boolean isFirstCapitalized) {
		StringBuilder builder = new StringBuilder(str.length());
		String[] tokens = NOT_ALPHANUMERIC_REGEX.split(str);
		for (int i = 0; i < tokens.length; i++) {
			String lowerCased = StringUtils.lowerCase(tokens[i]);
			if (i == 0) {
				builder.append(isFirstCapitalized ? StringUtils.capitalize(lowerCased) : lowerCased);
			} else {
				builder.append(StringUtils.capitalize(lowerCased));
			}
		}
		return builder.toString();
	}
1319612
function camelCaseToUnderscoreMap(columns) {
    var map = {};
    for (var i = 0; i < columns.length; i++)
        map[columns[i]] = toUnderscore(columns[i]);
    return map;
}
712632
function camelToKebab( string ) {
	return string.replace( ptnCamel, ( all, predecessor, match ) => predecessor + "-" + match.toLocaleLowerCase() );
}
65702
def camel_case(string):
    
    if not string:
        return string
    parts = snake_case(string).split('_')
    rv = ''
    while parts:
        part = parts.pop(0)
        rv += part or '_'
        if part:
            break
    return rv + ''.join(x.title() for x in parts)
1349177
def camel_case_to_under_score(camel_case_name):
    
    result = []
    for letter in camel_case_name:
        if letter.lower() != letter:
            result.append("_" + letter.lower())
        else:
            result.append(letter.lower())
    if result[0].startswith("_"):
        result[0] = result[0][1:]
    return "".join(result)
973023
def snake_case_to_camel_case(value)
      pieces = value.to_s.split '_'

      (pieces.first + pieces[1..-1].map(&:capitalize).join).to_sym
    end
743651
def to_snake_case(camel_case_string):
    
    first_pass = _first_camel_case_regex.sub(r'\1_\2', camel_case_string)
    return _second_camel_case_regex.sub(r'\1_\2', first_pass).lower()
427465
def camelCaseToDashName(camelCase):
        '''
            
        '''

        camelCaseList = list(camelCase)

        ret = []

        for ch in camelCaseList:
            if ch.isupper():
                ret.append('-')
                ret.append(ch.lower())
            else:
                ret.append(ch)

        return ''.join(ret)
1254351
def underscore(string)
      string = string.to_s
      string = string[0].downcase + string[1..-1].gsub(/([A-Z])/,'_\1')
      string.downcase
    end
257535
def camelcase_to_underscores(word):
    
    s1 = _FIRST_CAP_RE.sub(r'\1_\2', word)
    return _ALL_CAP_RE.sub(r'\1_\2', s1).lower()
1136120
def snake_case(string):
    
    if not string:
        return string
    string = string.replace('-', '_').replace(' ', '_')
    return de_camel(string)
737775
def underscore(camel_cased_word)
      return camel_cased_word unless camel_cased_word =~ /[A-Z-]/

      word = camel_cased_word.to_s

      word.gsub!(/([A-Z\d]+)([A-Z][a-z])/, '\1_\2')
      word.gsub!(/([a-z\d])([A-Z])/, '\1_\2')

      word.downcase!

      word
    end
787328
function underscoreToCamel (str) {
    str = str.charAt(0).toUpperCase() + str.slice(1);
    return str.replace(/\_(.)/g, function (x, chr) {
      return chr.toUpperCase();
    })
  }
770104
function camelCase(name: string): string {
  return name.replace(/([:\-_]+(.))/g, function(_, separator, letter, offset) {
    return offset ? letter.toUpperCase() : letter;
  });
}
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;
    }