I want to convert a string of the form ACT_PACKAGE_UTILITY to actPackageUtility but using Java 8. It's a piece of cake using Scala, for example
def underscoreToCamel(name: String) = "_([a-z\\d])".r.replaceAllIn
(name,{m => m.group(1).toUpperCase()
})
However, this seems quite complex in Java because the replaceAll in String does not accept a function.
Here is my attempt to get the values to insert the uppercase characters but I'm stuck.
Pattern pattern = Pattern.compile("_([a-z\\d])");
Matcher matcher = pattern.matcher(event.toLowerCase());
String evey=event.toLowerCase();
while(matcher.find()){
evey=evey.replace(evey.charAt(indexOf(matcher.group(1)),,
Character.toUpperCase(matcher.group(1).toCharArray()[0]);
}
Is there away to achieve it with Java 8?