---
title: "contains_text"
url: https://una-lang.org/en/docs/std/prelude/contains_text/
release: v0.4.0
edition: "0.2 and later"
source: https://github.com/una-lang/una/blob/v0.4.0/docs/std/listing.json
---

# contains_text

A function of the prelude, in scope in every module. Edition 0.2 and later.

```una
pub contains_text(t: Text, part: Text) -> Bool
```

Whether `part` occurs in `t` (`spec/22 §2`).

## Parameters

- `t`: the text
- `part`: the text to look for

## Returns

`Bool`: `true` when `part` occurs in `t`.

## Use instead

- [`find`](https://una-lang.org/en/docs/std/prelude/find/) to know where it occurs

## See also

[`starts_with`](https://una-lang.org/en/docs/std/prelude/starts_with/), [`ends_with`](https://una-lang.org/en/docs/std/prelude/ends_with/)

## Cost

Time `O(b + m)` (ADR 0070), where:

- `b`: the length of `t` in UTF\-8 bytes
- `m`: the length of `part` in UTF\-8 bytes

## Example

`src/shop.una`

```una
module shop

--- Whether a product description names a finish.
pub main() -> Unit
  uses @console: Console[print]
=
  let brass = "Desk lamp, brass".contains_text(part: "brass")
  @console.print("brass: {brass}")
  let steel = "Desk lamp, brass".contains_text(part: "steel")
  @console.print("steel: {steel}")
```

`una run .` prints:

```text
brass: true
steel: false
```

## Specification

- [`spec/22 §2`](https://una-lang.org/en/docs/spec/22-text/#s2)

Generated from the standard modules of una v0.4.0 ([`docs/std/listing.json`](https://github.com/una-lang/una/blob/5fec93d88932b333feec25e589355a2cb34c37b5/docs/std/listing.json), which is not part of the specification). The specification governs: [`spec/14 §1`](https://una-lang.org/en/docs/spec/14-standard-library/#s1).
