> ## Documentation Index
> Fetch the complete documentation index at: https://cantonfoundation-dpm-import.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# DA.Text

> Reference documentation for Daml module DA.Text.

<span id="module-da-text-83238" />

# DA.Text

Functions for working with Text.

## Module Snapshot

<CardGroup cols={2}>
  <Card title="Lifecycle">
    Stable.
  </Card>

  <Card title="Notices">
    Status: `active`
    Introduced in: `3.4.9`
    Removed in: `-`
    Warnings: `0`
    Deprecations: `0`
    Deprecated since: `-`
  </Card>
</CardGroup>

## Functions

<span id="function-da-text-explode-24206" />

### `explode`

`explode` : [`Text`](/appdev/reference/daml-standard-library/prelude#type-ghc-types-text-51952) -> \[[`Text`](/appdev/reference/daml-standard-library/prelude#type-ghc-types-text-51952)]

<span id="function-da-text-implode-82253" />

### `implode`

`implode` : \[[`Text`](/appdev/reference/daml-standard-library/prelude#type-ghc-types-text-51952)] -> [`Text`](/appdev/reference/daml-standard-library/prelude#type-ghc-types-text-51952)

<span id="function-da-text-isempty-39554" />

### `isEmpty`

`isEmpty` : [`Text`](/appdev/reference/daml-standard-library/prelude#type-ghc-types-text-51952) -> [`Bool`](/appdev/reference/daml-standard-library/prelude#type-ghc-types-bool-66265)

Test for emptiness.

<span id="function-da-text-isnotempty-43984" />

### `isNotEmpty`

`isNotEmpty` : [`Text`](/appdev/reference/daml-standard-library/prelude#type-ghc-types-text-51952) -> [`Bool`](/appdev/reference/daml-standard-library/prelude#type-ghc-types-bool-66265)

Test for non-emptiness.

<span id="function-da-text-length-94326" />

### `length`

`length` : [`Text`](/appdev/reference/daml-standard-library/prelude#type-ghc-types-text-51952) -> [`Int`](/appdev/reference/daml-standard-library/prelude#type-ghc-types-int-37261)

Compute the number of symbols in the text.

<span id="function-da-text-trim-11808" />

### `trim`

`trim` : [`Text`](/appdev/reference/daml-standard-library/prelude#type-ghc-types-text-51952) -> [`Text`](/appdev/reference/daml-standard-library/prelude#type-ghc-types-text-51952)

Remove spaces from either side of the given text.

<span id="function-da-text-replace-9445" />

### `replace`

`replace` : [`Text`](/appdev/reference/daml-standard-library/prelude#type-ghc-types-text-51952) -> [`Text`](/appdev/reference/daml-standard-library/prelude#type-ghc-types-text-51952) -> [`Text`](/appdev/reference/daml-standard-library/prelude#type-ghc-types-text-51952) -> [`Text`](/appdev/reference/daml-standard-library/prelude#type-ghc-types-text-51952)

Replace a subsequence everywhere it occurs. The first argument
must not be empty.

<span id="function-da-text-lines-25154" />

### `lines`

`lines` : [`Text`](/appdev/reference/daml-standard-library/prelude#type-ghc-types-text-51952) -> \[[`Text`](/appdev/reference/daml-standard-library/prelude#type-ghc-types-text-51952)]

Breaks a `Text` value up into a list of `Text`'s at newline
symbols. The resulting texts do not contain newline symbols.

<span id="function-da-text-unlines-66467" />

### `unlines`

`unlines` : \[[`Text`](/appdev/reference/daml-standard-library/prelude#type-ghc-types-text-51952)] -> [`Text`](/appdev/reference/daml-standard-library/prelude#type-ghc-types-text-51952)

Joins lines, after appending a terminating newline to each.

<span id="function-da-text-words-34636" />

### `words`

`words` : [`Text`](/appdev/reference/daml-standard-library/prelude#type-ghc-types-text-51952) -> \[[`Text`](/appdev/reference/daml-standard-library/prelude#type-ghc-types-text-51952)]

Breaks a 'Text' up into a list of words, delimited by symbols
representing white space.

<span id="function-da-text-unwords-40113" />

### `unwords`

`unwords` : \[[`Text`](/appdev/reference/daml-standard-library/prelude#type-ghc-types-text-51952)] -> [`Text`](/appdev/reference/daml-standard-library/prelude#type-ghc-types-text-51952)

Joins words using single space symbols.

<span id="function-da-text-linesby-11211" />

### `linesBy`

`linesBy` : ([`Text`](/appdev/reference/daml-standard-library/prelude#type-ghc-types-text-51952) -> [`Bool`](/appdev/reference/daml-standard-library/prelude#type-ghc-types-bool-66265)) -> [`Text`](/appdev/reference/daml-standard-library/prelude#type-ghc-types-text-51952) -> \[[`Text`](/appdev/reference/daml-standard-library/prelude#type-ghc-types-text-51952)]

A variant of `lines` with a custom test. In particular, if there
is a trailing separator it will be discarded.

<span id="function-da-text-wordsby-15461" />

### `wordsBy`

`wordsBy` : ([`Text`](/appdev/reference/daml-standard-library/prelude#type-ghc-types-text-51952) -> [`Bool`](/appdev/reference/daml-standard-library/prelude#type-ghc-types-bool-66265)) -> [`Text`](/appdev/reference/daml-standard-library/prelude#type-ghc-types-text-51952) -> \[[`Text`](/appdev/reference/daml-standard-library/prelude#type-ghc-types-text-51952)]

A variant of `words` with a custom test. In particular, adjacent
separators are discarded, as are leading or trailing separators.

<span id="function-da-text-intercalate-63059" />

### `intercalate`

`intercalate` : [`Text`](/appdev/reference/daml-standard-library/prelude#type-ghc-types-text-51952) -> \[[`Text`](/appdev/reference/daml-standard-library/prelude#type-ghc-types-text-51952)] -> [`Text`](/appdev/reference/daml-standard-library/prelude#type-ghc-types-text-51952)

`intercalate` inserts the text argument `t` in between the items
in `ts` and concatenates the result.

<span id="function-da-text-dropprefix-62361" />

### `dropPrefix`

`dropPrefix` : [`Text`](/appdev/reference/daml-standard-library/prelude#type-ghc-types-text-51952) -> [`Text`](/appdev/reference/daml-standard-library/prelude#type-ghc-types-text-51952) -> [`Text`](/appdev/reference/daml-standard-library/prelude#type-ghc-types-text-51952)

`dropPrefix` drops the given prefix from the argument. It returns
the original text if the text doesn't start with the given prefix.

<span id="function-da-text-dropsuffix-37682" />

### `dropSuffix`

`dropSuffix` : [`Text`](/appdev/reference/daml-standard-library/prelude#type-ghc-types-text-51952) -> [`Text`](/appdev/reference/daml-standard-library/prelude#type-ghc-types-text-51952) -> [`Text`](/appdev/reference/daml-standard-library/prelude#type-ghc-types-text-51952)

Drops the given suffix from the argument. It returns the original
text if the text doesn't end with the given suffix. Examples:

```
  dropSuffix "!" "Hello World!"  == "Hello World"
  dropSuffix "!" "Hello World!!" == "Hello World!"
  dropSuffix "!" "Hello World."  == "Hello World."
```

<span id="function-da-text-stripsuffix-58624" />

### `stripSuffix`

`stripSuffix` : [`Text`](/appdev/reference/daml-standard-library/prelude#type-ghc-types-text-51952) -> [`Text`](/appdev/reference/daml-standard-library/prelude#type-ghc-types-text-51952) -> [`Optional`](/appdev/reference/daml-standard-library/prelude#type-da-internal-prelude-optional-37153) [`Text`](/appdev/reference/daml-standard-library/prelude#type-ghc-types-text-51952)

Return the prefix of the second text if its suffix matches the
entire first text. Examples:

```
  stripSuffix "bar" "foobar" == Some "foo"
  stripSuffix ""    "baz"    == Some "baz"
  stripSuffix "foo" "quux"   == None
```

<span id="function-da-text-stripprefix-74987" />

### `stripPrefix`

`stripPrefix` : [`Text`](/appdev/reference/daml-standard-library/prelude#type-ghc-types-text-51952) -> [`Text`](/appdev/reference/daml-standard-library/prelude#type-ghc-types-text-51952) -> [`Optional`](/appdev/reference/daml-standard-library/prelude#type-da-internal-prelude-optional-37153) [`Text`](/appdev/reference/daml-standard-library/prelude#type-ghc-types-text-51952)

The `stripPrefix` function drops the given prefix from the
argument text.  It returns `None` if the text did not start with
the prefix.

<span id="function-da-text-isprefixof-82357" />

### `isPrefixOf`

`isPrefixOf` : [`Text`](/appdev/reference/daml-standard-library/prelude#type-ghc-types-text-51952) -> [`Text`](/appdev/reference/daml-standard-library/prelude#type-ghc-types-text-51952) -> [`Bool`](/appdev/reference/daml-standard-library/prelude#type-ghc-types-bool-66265)

The `isPrefixOf` function takes two text arguments and returns
`True` if and only if the first is a prefix of the second.

<span id="function-da-text-issuffixof-35218" />

### `isSuffixOf`

`isSuffixOf` : [`Text`](/appdev/reference/daml-standard-library/prelude#type-ghc-types-text-51952) -> [`Text`](/appdev/reference/daml-standard-library/prelude#type-ghc-types-text-51952) -> [`Bool`](/appdev/reference/daml-standard-library/prelude#type-ghc-types-bool-66265)

The `isSuffixOf` function takes two text arguments and returns
`True` if and only if the first is a suffix of the second.

<span id="function-da-text-isinfixof-98358" />

### `isInfixOf`

`isInfixOf` : [`Text`](/appdev/reference/daml-standard-library/prelude#type-ghc-types-text-51952) -> [`Text`](/appdev/reference/daml-standard-library/prelude#type-ghc-types-text-51952) -> [`Bool`](/appdev/reference/daml-standard-library/prelude#type-ghc-types-bool-66265)

The `isInfixOf` function takes two text arguments and returns
`True` if and only if the first is contained, wholly and intact,
anywhere within the second.

<span id="function-da-text-takewhile-40431" />

### `takeWhile`

`takeWhile` : ([`Text`](/appdev/reference/daml-standard-library/prelude#type-ghc-types-text-51952) -> [`Bool`](/appdev/reference/daml-standard-library/prelude#type-ghc-types-bool-66265)) -> [`Text`](/appdev/reference/daml-standard-library/prelude#type-ghc-types-text-51952) -> [`Text`](/appdev/reference/daml-standard-library/prelude#type-ghc-types-text-51952)

The function `takeWhile`, applied to a predicate `p` and a text,
returns the longest prefix (possibly empty) of symbols that satisfy
`p`.

<span id="function-da-text-takewhileend-32455" />

### `takeWhileEnd`

`takeWhileEnd` : ([`Text`](/appdev/reference/daml-standard-library/prelude#type-ghc-types-text-51952) -> [`Bool`](/appdev/reference/daml-standard-library/prelude#type-ghc-types-bool-66265)) -> [`Text`](/appdev/reference/daml-standard-library/prelude#type-ghc-types-text-51952) -> [`Text`](/appdev/reference/daml-standard-library/prelude#type-ghc-types-text-51952)

The function 'takeWhileEnd', applied to a predicate `p` and a
'Text', returns the longest suffix (possibly empty) of elements
that satisfy `p`.

<span id="function-da-text-dropwhile-46373" />

### `dropWhile`

`dropWhile` : ([`Text`](/appdev/reference/daml-standard-library/prelude#type-ghc-types-text-51952) -> [`Bool`](/appdev/reference/daml-standard-library/prelude#type-ghc-types-bool-66265)) -> [`Text`](/appdev/reference/daml-standard-library/prelude#type-ghc-types-text-51952) -> [`Text`](/appdev/reference/daml-standard-library/prelude#type-ghc-types-text-51952)

`dropWhile p t` returns the suffix remaining after `takeWhile p
t`.

<span id="function-da-text-dropwhileend-2917" />

### `dropWhileEnd`

`dropWhileEnd` : ([`Text`](/appdev/reference/daml-standard-library/prelude#type-ghc-types-text-51952) -> [`Bool`](/appdev/reference/daml-standard-library/prelude#type-ghc-types-bool-66265)) -> [`Text`](/appdev/reference/daml-standard-library/prelude#type-ghc-types-text-51952) -> [`Text`](/appdev/reference/daml-standard-library/prelude#type-ghc-types-text-51952)

`dropWhileEnd p t` returns the prefix remaining after dropping
symbols that satisfy the predicate `p` from the end of `t`.

<span id="function-da-text-spliton-44082" />

### `splitOn`

`splitOn` : [`Text`](/appdev/reference/daml-standard-library/prelude#type-ghc-types-text-51952) -> [`Text`](/appdev/reference/daml-standard-library/prelude#type-ghc-types-text-51952) -> \[[`Text`](/appdev/reference/daml-standard-library/prelude#type-ghc-types-text-51952)]

Break a text into pieces separated by the first text argument
(which cannot be empty), consuming the delimiter.

<span id="function-da-text-splitat-25614" />

### `splitAt`

`splitAt` : [`Int`](/appdev/reference/daml-standard-library/prelude#type-ghc-types-int-37261) -> [`Text`](/appdev/reference/daml-standard-library/prelude#type-ghc-types-text-51952) -> ([`Text`](/appdev/reference/daml-standard-library/prelude#type-ghc-types-text-51952), [`Text`](/appdev/reference/daml-standard-library/prelude#type-ghc-types-text-51952))

Split a text before a given position so that for `0 <= n <= length t`,
`length (fst (splitAt n t)) == n`.

<span id="function-da-text-take-27133" />

### `take`

`take` : [`Int`](/appdev/reference/daml-standard-library/prelude#type-ghc-types-int-37261) -> [`Text`](/appdev/reference/daml-standard-library/prelude#type-ghc-types-text-51952) -> [`Text`](/appdev/reference/daml-standard-library/prelude#type-ghc-types-text-51952)

`take n`, applied to a text `t`, returns the prefix of `t` of
length `n`, or `t` itself if `n` is greater than the length of `t`.

<span id="function-da-text-drop-34163" />

### `drop`

`drop` : [`Int`](/appdev/reference/daml-standard-library/prelude#type-ghc-types-int-37261) -> [`Text`](/appdev/reference/daml-standard-library/prelude#type-ghc-types-text-51952) -> [`Text`](/appdev/reference/daml-standard-library/prelude#type-ghc-types-text-51952)

`drop n`, applied to a text `t`, returns the suffix of `t` after
the first `n` characters, or the empty `Text` if `n` is greater
than the length of `t`.

<span id="function-da-text-substring-36270" />

### `substring`

`substring` : [`Int`](/appdev/reference/daml-standard-library/prelude#type-ghc-types-int-37261) -> [`Int`](/appdev/reference/daml-standard-library/prelude#type-ghc-types-int-37261) -> [`Text`](/appdev/reference/daml-standard-library/prelude#type-ghc-types-text-51952) -> [`Text`](/appdev/reference/daml-standard-library/prelude#type-ghc-types-text-51952)

Compute the sequence of symbols of length `l` in the argument
text starting at `s`.

<span id="function-da-text-ispred-73747" />

### `isPred`

`isPred` : ([`Text`](/appdev/reference/daml-standard-library/prelude#type-ghc-types-text-51952) -> [`Bool`](/appdev/reference/daml-standard-library/prelude#type-ghc-types-bool-66265)) -> [`Text`](/appdev/reference/daml-standard-library/prelude#type-ghc-types-text-51952) -> [`Bool`](/appdev/reference/daml-standard-library/prelude#type-ghc-types-bool-66265)

`isPred f t` returns `True` if `t` is not empty and `f` is `True`
for all symbols in `t`.

<span id="function-da-text-isspace-72803" />

### `isSpace`

`isSpace` : [`Text`](/appdev/reference/daml-standard-library/prelude#type-ghc-types-text-51952) -> [`Bool`](/appdev/reference/daml-standard-library/prelude#type-ghc-types-bool-66265)

`isSpace t` is `True` if `t` is not empty and consists only of
spaces.

<span id="function-da-text-isnewline-85831" />

### `isNewLine`

`isNewLine` : [`Text`](/appdev/reference/daml-standard-library/prelude#type-ghc-types-text-51952) -> [`Bool`](/appdev/reference/daml-standard-library/prelude#type-ghc-types-bool-66265)

`isSpace t` is `True` if `t` is not empty and consists only of
newlines.

<span id="function-da-text-isupper-58977" />

### `isUpper`

`isUpper` : [`Text`](/appdev/reference/daml-standard-library/prelude#type-ghc-types-text-51952) -> [`Bool`](/appdev/reference/daml-standard-library/prelude#type-ghc-types-bool-66265)

`isUpper t` is `True` if `t` is not empty and consists only of
uppercase symbols.

<span id="function-da-text-islower-60966" />

### `isLower`

`isLower` : [`Text`](/appdev/reference/daml-standard-library/prelude#type-ghc-types-text-51952) -> [`Bool`](/appdev/reference/daml-standard-library/prelude#type-ghc-types-bool-66265)

`isLower t` is `True` if `t` is not empty and consists only of
lowercase symbols.

<span id="function-da-text-isdigit-15622" />

### `isDigit`

`isDigit` : [`Text`](/appdev/reference/daml-standard-library/prelude#type-ghc-types-text-51952) -> [`Bool`](/appdev/reference/daml-standard-library/prelude#type-ghc-types-bool-66265)

`isDigit t` is `True` if `t` is not empty and consists only of
digit symbols.

<span id="function-da-text-isalpha-72233" />

### `isAlpha`

`isAlpha` : [`Text`](/appdev/reference/daml-standard-library/prelude#type-ghc-types-text-51952) -> [`Bool`](/appdev/reference/daml-standard-library/prelude#type-ghc-types-bool-66265)

`isAlpha t` is `True` if `t` is not empty and consists only of
alphabet symbols.

<span id="function-da-text-isalphanum-87978" />

### `isAlphaNum`

`isAlphaNum` : [`Text`](/appdev/reference/daml-standard-library/prelude#type-ghc-types-text-51952) -> [`Bool`](/appdev/reference/daml-standard-library/prelude#type-ghc-types-bool-66265)

`isAlphaNum t` is `True` if `t` is not empty and consists only of
alphanumeric symbols.

<span id="function-da-text-parseint-736" />

### `parseInt`

`parseInt` : [`Text`](/appdev/reference/daml-standard-library/prelude#type-ghc-types-text-51952) -> [`Optional`](/appdev/reference/daml-standard-library/prelude#type-da-internal-prelude-optional-37153) [`Int`](/appdev/reference/daml-standard-library/prelude#type-ghc-types-int-37261)

Attempt to parse an `Int` value from a given `Text`.

<span id="function-da-text-parsenumeric-9858" />

### `parseNumeric`

`parseNumeric` : [`NumericScale`](/appdev/reference/daml-standard-library/prelude#class-ghc-classes-numericscale-83720) `n` => [`Text`](/appdev/reference/daml-standard-library/prelude#type-ghc-types-text-51952) -> [`Optional`](/appdev/reference/daml-standard-library/prelude#type-da-internal-prelude-optional-37153) ([`Numeric`](/appdev/reference/daml-standard-library/prelude#type-ghc-types-numeric-891) `n`)

Attempt to parse a `Numeric` value from a given `Text`.
To get `Some` value, the text must follow the regex
`(-|\+)?[0-9]+(\.[0-9]+)?`
In particular, the shorthands `".12"` and `"12."` do not work,
but the value can be prefixed with `+`.
Leading and trailing zeros are fine, however spaces are not.
Examples:

```
  parseNumeric "3.14" == Some 3.14
  parseNumeric "+12.0" == Some 12
```

<span id="function-da-text-parsedecimal-57278" />

### `parseDecimal`

`parseDecimal` : [`Text`](/appdev/reference/daml-standard-library/prelude#type-ghc-types-text-51952) -> [`Optional`](/appdev/reference/daml-standard-library/prelude#type-da-internal-prelude-optional-37153) [`Decimal`](/appdev/reference/daml-standard-library/prelude#type-ghc-types-decimal-18135)

Attempt to parse a `Decimal` value from a given `Text`.
To get `Some` value, the text must follow the regex
`(-|\+)?[0-9]+(\.[0-9]+)?`
In particular, the shorthands `".12"` and `"12."` do not work,
but the value can be prefixed with `+`.
Leading and trailing zeros are fine, however spaces are not.
Examples:

```
  parseDecimal "3.14" == Some 3.14
  parseDecimal "+12.0" == Some 12
```

<span id="function-da-text-sha256-29291" />

### `sha256`

`sha256` : [`Text`](/appdev/reference/daml-standard-library/prelude#type-ghc-types-text-51952) -> [`Text`](/appdev/reference/daml-standard-library/prelude#type-ghc-types-text-51952)

Computes the SHA256 hash of the UTF8 bytes of the `Text`, and returns it in its hex-encoded
form. The hex encoding uses lowercase letters.

This function will crash at runtime if you compile Daml to Daml-LF \< 1.2.

<span id="function-da-text-reverse-37387" />

### `reverse`

`reverse` : [`Text`](/appdev/reference/daml-standard-library/prelude#type-ghc-types-text-51952) -> [`Text`](/appdev/reference/daml-standard-library/prelude#type-ghc-types-text-51952)

Reverse some `Text`.

```
  reverse "Daml" == "lmaD"
```

<span id="function-da-text-tocodepoints-44801" />

### `toCodePoints`

`toCodePoints` : [`Text`](/appdev/reference/daml-standard-library/prelude#type-ghc-types-text-51952) -> \[[`Int`](/appdev/reference/daml-standard-library/prelude#type-ghc-types-int-37261)]

Convert a `Text` into a sequence of unicode code points.

<span id="function-da-text-fromcodepoints-94464" />

### `fromCodePoints`

`fromCodePoints` : \[[`Int`](/appdev/reference/daml-standard-library/prelude#type-ghc-types-int-37261)] -> [`Text`](/appdev/reference/daml-standard-library/prelude#type-ghc-types-text-51952)

Convert a sequence of unicode code points into a `Text`. Raises an
exception if any of the code points is invalid.

<span id="function-da-text-asciitolower-24557" />

### `asciiToLower`

`asciiToLower` : [`Text`](/appdev/reference/daml-standard-library/prelude#type-ghc-types-text-51952) -> [`Text`](/appdev/reference/daml-standard-library/prelude#type-ghc-types-text-51952)

Convert the uppercase ASCII characters of a `Text` to lowercase;
all other characters remain unchanged.

<span id="function-da-text-asciitoupper-96826" />

### `asciiToUpper`

`asciiToUpper` : [`Text`](/appdev/reference/daml-standard-library/prelude#type-ghc-types-text-51952) -> [`Text`](/appdev/reference/daml-standard-library/prelude#type-ghc-types-text-51952)

Convert the lowercase ASCII characters of a `Text` to uppercase;
all other characters remain unchanged.
