# Substring

The **Substring** function is an alias of **Mid**.\
Returns a substring defined by offset and length.

### Usage

```
Substring(string, start, [length])
```

**string** (required) The string to extract a substring from.

**start** (required) The index of the first letter of the extracted substring. The first character of the given string is treated as having index 1.

**length** (optional) The length of the segment to extract. If length is not given, or if the provided length is longer than the remaining source string, the total remaining string will be returned.

### Example

You can use this function in combination with the [Find](/uma-knowledgebase/data-and-reporting/analytics-pro/functions/text-functions/find.md) function to identify mentions of a given word in a transcript and output the surrounding text.

For example, given a column **Transcript**, retrieve 200 characters of text after the word "Space":

```
Substring([Transcript], (Find([Transcript], "Space"), 200)
```

Returns a string of text excerpted from the transcript, starting from the word Space.

To retrieve the text in the transcript before and after the given word, you can use this function twice and concatenate the results with the [Concat](/uma-knowledgebase/data-and-reporting/analytics-pro/functions/text-functions/concat.md) function or the `&` character. For example, given a column **Transcript**, retrieve 200 characters before and 200 characters of text after the word "Space":

```
(Substring([Transcript], (Find([Transcript], "Space") - 200), 200)) 
& (Substring([Transcript], Find([Transcript], "Space"), 200))
```

Returns a string of text excerpted from the transcript, starting 200 characters before the word Space, and ending 200 characters after the word Space.

For example, extract 10 characters from a given string, starting at index 4:

```
Substring(“John Doe”, 4, 10)
```

Returns "n Doe".

As another example, extracting data at index 4 for a string length of 3 characters returns an empty string:

```
Substring(“Mia”, 4)
```

Returns "", an empty string.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://support.meetuma.ai/uma-knowledgebase/data-and-reporting/analytics-pro/functions/text-functions/substring.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
