Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 2 additions & 9 deletions src/String/Extra.elm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down