Kebab-case captialization
@@ -77,16 +77,16 @@ public class Strings{
return new String(new char[Math.abs((int)(time / scale) % length)]).replace("\0", replacement);
}
- /**Converts a snake_case string to Upper Case.
+ /**Converts a snake_case or kebab-case string to Upper Case.
* For example: "test_string" -> "Test String"*/
public static String capitalize(String s){
StringBuilder result = new StringBuilder(s.length());
for(int i = 0; i < s.length(); i++){
char c = s.charAt(i);
- if(c == '_'){
+ if(c == '_' || c == '-'){
result.append(" ");
- }else if(i == 0 || s.charAt(i - 1) == '_'){
+ }else if(i == 0 || s.charAt(i - 1) == '_' || s.charAt(i - 1) == '-'){
result.append(Character.toUpperCase(c));
}else{
result.append(c);
