I used to use org.apache.commons.lang3.text.WordUtils.capitalizeFully()
but I have been having problems. I made my own method in Groovy.
def capitalizeFully(String str, String delim=" ") { //optional delimiter
def li = []
str.split(delim).each { word ->
li.add(word.capitalize())
}
return li.join(delim)
}
assert capitalizeFully("A silly string with words") == "A Silly String With Words"
Top comments (0)