Convert from title or camelCase to snake_case.
12404
def snake(s):
    """"""
    if len(s) < 2:
        return s.lower()
    out = s[0].lower()
    for c in s[1:]:
        if c.isupper():
            out += "_"
            c = c.lower()
        out += c
    return out
76412
def snake_to_camel(s: str) -> str:
    """"""

    fragments = s.split('_')

    return fragments[0] + ''.join(x.title() for x in fragments[1:])
372376
def snake_to_pascal(snake_str):
    '''
    
    '''
    components = snake_str.split('_')
    if len(components) > 1:
        camel = ''.join(x.title() for x in components)
        return camel
    # Not snake_case
    return snake_str
881530
public static String fromSnakeCaseToCamelCase(String text) {
    if (isNullOrEmpty(text)) {
      return text;
    }
    String[] array = text.split("_");
    if (array.length == 0) {
      return "";
    }
    StringBuilder result = new StringBuilder();
    result.append(array[0].toLowerCase());
    for (int i = 1; i < array.length; i++) {
      String s = capitalize(array[i].toLowerCase());
      result.append(s);
    }
    return result.toString();
  }
951012
def camel_case_to_name(name):
    
    def convert_func(val):
        return "_" + val.group(0).lower()
    return name[0].lower() + re.sub(r'([A-Z])', convert_func, name[1:])
1124398
def title_case(string):
    
    if not string:
        return string
    string = string.replace('_', ' ').replace('-', ' ')
    parts = de_camel(string, ' ', _lowercase=False).strip().split(' ')
    return ' '.join([part if part.isupper() else part.title()
                     for part in parts])
1120497
function camelCase(str) {
  if (str.indexOf('_') > -1) {
    str = str.replace(/_(\w)/g, (a, b) => {
      return b.toUpperCase();
    });
  }
  return str;
}
1113533
def lower_camel_case_from_underscores(string):
    """"""
    components = string.split('_')
    string = components[0]
    for component in components[1:]:
        string += component[0].upper() + component[1:]
    return string
715535
def snake_to_camel(value):
    
    camel = "".join(word.title() for word in value.split("_"))
    return value[:1].lower() + camel[1:]
747890
function camelCase(input) {
  let str = input.toLowerCase().replace(/-(.)/g, function (match, group1) {
    return group1.toUpperCase();
  });

  str = str.replace(/_(.)/g, function (match, group1) {
    return group1.toUpperCase();
  });
  return str
}
720585
public static String snakeCaseToCamelCase(String snakeCase) {
		if(snakeCase.contains("-")) {
			StringBuilder camelCaseStr = new StringBuilder(snakeCase.length());
			boolean toUpperCase = false;
			for (char c : snakeCase.toCharArray()) {
				if (c == '-')
					toUpperCase = true;
				else {
					if (toUpperCase) {
						toUpperCase = false;
						c = Character.toUpperCase(c);
					}
					camelCaseStr.append(c);
				}
			}
			snakeCase = camelCaseStr.toString();
		}
		return snakeCase;
	}
1080611
def _snake_case(cls, text):
        
        if text.islower():
            return text
        return cls._screaming_snake_case(text).lower()
932061
public static function convertCamelCaseToSnakeCase(string $value): string
    {
        if (isset(self::$snakeCache[$value])) {
            return self::$snakeCache[$value];
        }

        $withUpperArray = str_split($value);

        $snake_case = '';
        foreach ($withUpperArray as $letter) {
            if (preg_match("/[A-Z]/", $letter)) {
                $snake_case .= '_'.mb_strtolower($letter);
            } else {
                $snake_case .= $letter;
            }
        }

        return self::$snakeCache[$value] = $snake_case;
    }
1108618
def camel_case_to_snake_case(name):
    
    s1 = _FIRST_CAP_RE.sub(r'\1_\2', name)
    return _ALL_CAP_RE.sub(r'\1_\2', s1).lower()
202442
def convert_camel_case_string(name: str) -> str:
    """"""
    string = re.sub("(.)([A-Z][a-z]+)", r"\1_\2", name)
    return re.sub("([a-z0-9])([A-Z])", r"\1_\2", string).lower()
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
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:])