All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.meluzin.strings.NameNormalizer Maven / Gradle / Ivy

There is a newer version: 1.2
Show newest version
package com.meluzin.strings;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class NameNormalizer {
	public String normalize(String underscoreSeparatedName) {
		underscoreSeparatedName = underscoreSeparatedName.replaceAll("_+", "_").replaceAll("_*$", "").toLowerCase();
		Matcher m  = Pattern.compile("_(.)").matcher(underscoreSeparatedName);
		StringBuffer sb = new StringBuffer();
		while (m.find()) {
			m.appendReplacement(sb, m.group().substring(1).toUpperCase());
		}
		m.appendTail(sb);
 		return sb.toString();
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy