=begin
Converts the string into snake case format.
=end
320234
def to_underscore(value)
      underscore_value = value.gsub(/::/, '/').gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').
      gsub(/([a-z\d])([A-Z])/,'\1_\2').tr("-", "_").downcase
      return underscore_value
    end
941103
def to_snake_case(s):
    """"""
    return re.sub('([^_A-Z])([A-Z])', lambda m: m.group(1) + '_' + m.group(2).lower(), s)
573876
def normalize_keys(suspect, snake_case=True):
    
    if not isinstance(suspect, dict):
        raise TypeError('you must pass a dict.')

    for key in list(suspect):
        if not isinstance(key, six.string_types):
            continue

        if snake_case:
            s1 = first_cap_re.sub(r'\1_\2', key)
            new_key = all_cap_re.sub(r'\1_\2', s1).lower()  # .replace('-', '_')
        else:
            new_key = key.lower()

        value = suspect.pop(key)
        if isinstance(value, dict):
            suspect[new_key] = normalize_keys(value, snake_case)
        elif isinstance(value, list):
            for i in range(0, len(value)):
                if isinstance(value[i], dict):
                    normalize_keys(value[i], snake_case)

            suspect[new_key] = value
        else:
            suspect[new_key] = value

    return suspect
63754
public String substringBetween(String string, String begin, String end) {
		return substringBetween(string, begin, end, false);
	}
1315599
def charspan(cls, start, end):
        
        return cls(Lnk.CHARSPAN, (int(start), int(end)))
959142
function toCookedString(s) {
  let sb = ['"'];
  let i = 0, k = 1, c, c2;
  while (i < s.length) {
    c = s[i++];
    switch (c) {
      case '\\':
        c2 = s[i++];
        switch (c2) {
          // Strip line continuation.
          case '\n':
          case '\u2028':
          case '\u2029':
            break;
          case '\r':
            // \ \r \n should be stripped as one
            if (s[i + 1] === '\n') {
              i++;
            }
            break;

          default:
            sb[k++] = c;
            sb[k++] = c2;
        }
        break;

      // Since we wrap the string in " we need to escape those.
      case '"':
        sb[k++] = '\\"';
        break;

      // Whitespace
      case '\n':
        sb[k++] = '\\n';
        break;
      // <CR><LF> and <CR> LineTerminatorSequences are normalized to <LF>
      // for both TV and TRV.
      case '\r':
        if (s[i] === '\n')
          i++;
        sb[k++] = '\\n';
        break;
      case '\t':
        sb[k++] = '\\t';
        break;
      case '\f':
        sb[k++] = '\\f';
        break;
      case '\b':
        sb[k++] = '\\b';
        break;
      case '\u2028':
        sb[k++] = '\\u2028';
        break;
      case '\u2029':
        sb[k++] = '\\u2029';
        break;

      default:
        sb[k++] = c;
    }
  }

  sb[k++] = '"';
  return sb.join('');
}
906824
def snake2ucamel(value):
    """"""
    UNDER, LETTER, OTHER = object(), object(), object()
    def group_key_function(char):
        if char == "_":
            return UNDER
        if char in string.ascii_letters:
            return LETTER
        return OTHER
    def process_group(idx, key, chars):
        if key is LETTER:
            return "".join([chars[0].upper()] + chars[1:])
        if key is OTHER     \
        or len(chars) != 1  \
        or idx in [0, last] \
        or LETTER not in (groups[idx-1][1], groups[idx+1][1]):
            return "".join(chars)
        return ""
    raw_groups_gen = itertools.groupby(value, key=group_key_function)
    groups = [(idx, key, list(group_gen))
              for idx, (key, group_gen) in enumerate(raw_groups_gen)]
    last = len(groups) - 1
    return "".join(itertools.starmap(process_group, groups))
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()
959491
private StringGrabber replaceCaseTo(int startPos, int endPos, ECase toCase) {

		StringBuilder sbRange = new StringBuilder();

		try {
			for (int i = startPos; i < endPos; i++) {
				sbRange.append(String.valueOf(sb.charAt(i)));
			}
		} catch (Exception e) {
			e.printStackTrace();
		}

		final String caseConvertedRangeStr;

		if (ECase.LOWER == toCase) {
			caseConvertedRangeStr = sbRange.toString().toLowerCase();
		} else {
			caseConvertedRangeStr = sbRange.toString().toUpperCase();
		}
		try {
			sb.replace(startPos, endPos, caseConvertedRangeStr);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return StringGrabber.this;
	}
138381
public static boolean isLetter(String str, int beginIndex, int endIndex)
    {
        for ( int i = beginIndex; i < endIndex; i++ ) {
            char chr = str.charAt(i);
            if ( ! StringUtil.isEnLetter(chr) ) {
                return false;
            }
        }

        return true;
    }
458200
function snakeCase(str) {
            return camelCase(str).replace(reCamelCase, function (all, letter) {
                return "-" + letter.toLowerCase();
            });
        }
798542
def snake_to_camel(snake_str):
    '''
    
    '''
    components = snake_str.split('_')
    if len(components) > 1:
        camel = (components[0].lower() +
                 ''.join(x.title() for x in components[1:]))
        return camel
    # Not snake_case
    return snake_str
1208686
def parse_case_snake_to_camel(snake, upper_first=True):
	
	snake = snake.split('_')
	first_part = snake[0]
	if upper_first:
		first_part = first_part.title()
	return first_part + ''.join(word.title() for word in snake[1:])
1069536
def camelize(string, lowercase = false)
      result = string
        .to_s
        .split("_")
        .map { |e| e.capitalize }
        .join

      if lowercase
        result[0, 1].downcase + result[1..-1]
      else
        result
      end
    end
140806
def snake_to_pascal(name, singularize=False):
  
  parts = name.split("_")
  if singularize:
    return "".join(p.upper() if p in _ALL_CAPS else to_singular(p.title()) for p in parts)
  else:
    return "".join(p.upper() if p in _ALL_CAPS else p.title() for p in parts)
383122
public String mkString(String start, String sep, String end) {
		StringBuilder ret = new StringBuilder(start);
		for (int i = 0; i < inner.size(); i++) {
			ret.append(inner.get(i));
			if (i != (inner.size() - 1)) {
				ret.append(sep);
			}
		}
		return ret.append(end).toString();
	}
1053636
protected function snakeToCamelCase($string, $smallFirst = false)
    {
        $parts = explode('_', $string);

        array_walk($parts, function(&$element) {
           $element = ucfirst($element);
        });

        $result = implode('', $parts);

        return $smallFirst ? lcfirst($result) : $result;
    }