# extract

## Description

Extract a specific length of characters from a string of text.

## Input / Parameter

| Name   | Description                                        | Input Type | Default | Options               | Required                                 |
| ------ | -------------------------------------------------- | ---------- | ------- | --------------------- | ---------------------------------------- |
| type   | The part of the string to extract characters from. | Text       | -       | Left , Middle , Right | Yes                                      |
| text   | The string of text to extract from.                | Text       | -       | -                     | Yes                                      |
| length | The length of characters to extract.               | Number     | -       | -                     | Yes                                      |
| start  | The index to start extracting from.                | Number     | -       | -                     | Yes (Applicable for type ‘Middle’ only.) |

## Output

| Description                           | Output Type |
| ------------------------------------- | ----------- |
| Returns the extracted string of text. | String/Text |

## Example

In this example, we will extract a part of a text using extract function.

### Steps

1. Drag a `button` component into the canvas and open the `Action` tab. Select the `press` event of the button.
2. Add `Log.write` function and add a subflow on it's value, then put `Text.extract` inside it and fill type param with `Left` and the text param with `Hello, 世界🌍!` and length param with `5`.

   ![](https://399701567-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FwmJ1RKjM2uNFaL6fO3Xu%2Fuploads%2Fgit-blob-fcfa8d3959278daf3ea26f409acb15927dac2ebe%2Fextract-step-1.png?alt=media)
3. Add `Log.write` function and add a subflow on it's value, then put `Text.extract` inside it and fill type param with `Right` and the text param with `Hello, 世界🌍!` and length param with `6`.

   ![](https://399701567-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FwmJ1RKjM2uNFaL6fO3Xu%2Fuploads%2Fgit-blob-e6d5b26e04a24d3303afc5e0a69d848999c661b3%2Fextract-step-2.png?alt=media)
4. Add `Log.write` function and add a subflow on it's value, then put `Text.extract` inside it and fill type param with `Middle` and the text param with `Hello, 世界🌍!` and length param with `5` and start param with `7`.

   ![](https://399701567-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FwmJ1RKjM2uNFaL6fO3Xu%2Fuploads%2Fgit-blob-b4e67186f21ab4d4601fc01a85a3c6550c9f62eb%2Fextract-step-3.png?alt=media)

### Result

1. The console on preview will show us the formatted text value `Hello`, `世界🌍!` & `世界🌍!`.

   ![](https://399701567-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FwmJ1RKjM2uNFaL6fO3Xu%2Fuploads%2Fgit-blob-0c34a99fa807ab273e262b58824781e52871d428%2Fextract-result-1.png?alt=media)

## Links

### Related Information
