Do I need to convert a string to letter case (correct case or title), is there any default function to support Groovy for this, or do I need to manually substitute the first character?
assert org.apache.commons.lang.WordUtils.capitalizeFully('man OF stEEL') == 'Man Of Steel'
The class is WordUtilsprovided by Apache Commons Lang, which is available on the way to Grails application classes using defatult
WordUtils
yes you can use the capitalize () method
http://groovy.codehaus.org/groovy-jdk/java/lang/String.html#capitalize%28%29
, ,
assert "John Doe" == "john dOE".tokenize(" ")*.toLowerCase()*.capitalize().join(" ")
,
def capitalize(s) { s[0].toUpperCase() + s[1..-1].toLowerCase() } caps = "man OF stEEL".replaceAll(/\w+/) { w -> capitalize(w) }
Source: https://habr.com/ru/post/1541988/More articles:Haskell type-safe `read` - haskellEnabling PHP APC request caching - phpEvernote resource updates for notes - pythonAuto-Comment New Line, SublimeText - commentsHow to run a store to view? - c #Как сохранить сопоставление между строкой и индексом в C? - cJava - Generics - Explicit casting and casting method of the "Class "- javaOozi's jobs hit statewide - javaGiven the sequence of mappings in Clojure, how do I filter the key value> (some value)? - dictionaryHow to check the working platform in Portable Class Library? - c #All Articles