docs-v2/content/v2.0/reference/flux/functions/strings/totitle.md

1.1 KiB

title description menu weight related
strings.toTitle() function The strings.toTitle() function converts all characters in a string to title case.
v2_0_ref
name parent
strings.toTitle Strings
301
/v2.0/reference/flux/functions/strings/toupper
/v2.0/reference/flux/functions/strings/tolower
/v2.0/reference/flux/functions/strings/title

The strings.toTitle() function converts all characters in a string to title case.

Output data type: String

import "strings"

strings.toTitle(v: "a flux of foxes")

// returns "A FLUX OF FOXES"

Parameters

v

The string value to convert.

Data type: String

Examples

Covert characters in a string to title case
import "strings"

data
  |> map(fn: (r) => ({ r with pageTitle: strings.toTitle(v: r.pageTitle) }))

{{% note %}}

The difference between toTitle and toUpper

The results of toTitle() and toUpper are often the same, however the difference is visible with special characters:

str = "dz"

strings.toTitle(v: str) // Returns Dz
strings.toUpper(v: str) // Returns DZ

{{% /note %}}