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

# starts_with

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

```una
pub starts_with(t: Text, prefix: Text) -> Bool
```

Whether `t` starts with `prefix`, comparing Unicode scalar values (`spec/14 §1`).

## Parameters

- `t`: the text
- `prefix`: the text `t` may start with

## Returns

`Bool`: `true` when the first scalar values of `t` are those of `prefix`.

## See also

[`ends_with`](https://una-lang.org/en/docs/std/prelude/ends_with/) (edition 0.2 on), [`contains_text`](https://una-lang.org/en/docs/std/prelude/contains_text/) (edition 0.2 on)

## Example

`src/shop.una`

```una
module shop

--- Whether an SKU belongs to the lamp range.
pub main() -> Unit
  uses @console: Console[print]
=
  let lamp = starts_with("LAMP-01", prefix: "LAMP")
  @console.print("LAMP-01: {lamp}")
  let lower = starts_with("lamp-01", prefix: "LAMP")
  @console.print("lamp-01: {lower}")
```

`una run .` prints:

```text
LAMP-01: true
lamp-01: false
```

## Specification

- [`spec/14 §1`](https://una-lang.org/en/docs/spec/14-standard-library/#s1)

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).
