diff --git a/src/String/Extra.elm b/src/String/Extra.elm index 5fd06b8..8472cdc 100644 --- a/src/String/Extra.elm +++ b/src/String/Extra.elm @@ -147,15 +147,8 @@ decapitalize word = -} toTitleCase : String -> String -toTitleCase ws = - let - uppercaseMatch = - Regex.replace (regexFromString "\\w+") (.match >> toSentenceCase) - in - ws - |> Regex.replace - (regexFromString "^([a-z])|\\s+([a-z])") - (.match >> uppercaseMatch) +toTitleCase phrase = + phrase |> String.split " " |> List.map String.toSentenceCase |> String.join " " {-| Replace text within a portion of a string given a substitution