# Get Sub String

This is a pre-built Action located under the **@Generic Element**. The functionality of this Action in Avo Assure is to extract a specific part of the input text based on the given index or range. The extracted portion is stored in a dynamic variable.

## **Syntax**&#x20;

**Input Value**: `<string>;<index OR range>`&#x20;

| Argument                                | Description                                                      |
| --------------------------------------- | ---------------------------------------------------------------- |
| <p>\<string ><br>(Required)</p>         | Provide the full string from which you want to extract a part.   |
| <p>\<index OR range ><br>(Required)</p> | Provide the position or range of characters you want to extract. |

{% hint style="info" %}
**Note**:&#x20;

* The index value starts from the 0<sup>th</sup> index till N<sup>th</sup>  index.
* **Index**: The extraction starts from the given index and continues until the end of the string.
* **Range**: Use the format StartIndex–EndIndex. The extraction starts from the StartIndex and stops just before the EndIndex. To include the last character, increase the EndIndex by **1** (total range+1).
  {% endhint %}

**Output Value**: `<Dynamic Varibale>;<Dynamic Variable>(Optional)`

| Argument                                  | Description                                                       |
| ----------------------------------------- | ----------------------------------------------------------------- |
| <p>\<Dynamic Variable><br>(Required)</p>  | This dynamic variable stores a specific portion of a string.      |
| <p>\<Dynamic Variable><br>(Optional) </p> | This dynamic variable stores the status as **True** or **False**. |

### **Example 1: Extracting a Substring from a String Using Index Value**

In this example, we explain how to extract a part of a string starting from a specific index in Input Value.

* **Action**: Get Sub String
* **Input Value**: Software Engineer;4
  * The first argument (**Software Engineer**) specifies the main string,&#x20;
  * The second argument (**4**) specifies the starting index from which the substring is extracted.
* **Output Value**: {Sub string}
  * The extracted substring (ware Engineer) is stored in this **{Sub string}** dynamic variable for further use.
  * If the second output variable is defined, it stores the action status with the following possible values:
    * **True**: If the substring is successfully extracted.
    * **False**: If the input value is empty or invalid.
* **Logical Explanation**: The **Get Sub String** action fetches the value from the **Input Value** column (**Software Engineer;4**) and extracts the substring starting from the specified index (4). For the given input, the resulting substring is (ware Engineer). The extracted substring is stored in the **{Sub string}** variable.

<figure><img src="/files/upVsUNiPgL60vtSwbS87" alt=""><figcaption></figcaption></figure>

### **Example 2:** Extracting a Substring **from a String** Using a Range Value

In this example, we explain how to extract a part of a string using a specific range in Input Value.

* **Action**: Get Sub String
* **Input Value**: Software Engineer;9–17
  * The first argument (**Software Engineer**) specifies the main string,&#x20;
  * The second argument (**9–17**) defines the range of characters to extract.
* **Output Value**: {Sub string}
  * The extracted substring (Engineer) is stored in this **{Sub string}** dynamic variable for further use.
  * If the second output variable is defined, it stores the action status with the following possible values:
    * **True**: If the substring is successfully extracted.
    * **False**: If the extraction fails due to an invalid range or input.
* **Logical Explanation**: The **Get Sub String** action fetches the value from the **Input Value** column (**Software Engineer;9-17**) and extracts the substring based on the specified range (9–17). For the given input string, the resulting substring is (Engineer). The extracted substring is stored in the **{Sub string}** variable.

<figure><img src="/files/HAas9CMxw3jrJsOfAAZF" alt=""><figcaption></figcaption></figure>

#### **Knowledge Bites:**&#x20;

Here are some examples of different string scenarios:

| String               | Input Value                                                                                                                                                | Result                                                                                                         |
| -------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------- |
| Text Strings         | <p><strong>index:</strong> Automation;4</p><p>                         <strong>OR</strong></p><p><strong>range:</strong> Automation;3-10 </p>              | <p><strong>index:</strong> mation</p><p>    <strong>OR</strong></p><p><strong>range:</strong> omation</p>      |
| Numeric Strings      | <p><strong>index:</strong> 12345678;4 </p><p>                         <strong>OR</strong></p><p><strong>range:</strong> 12345678;3-10</p>                  | <p><strong>index:</strong> 5678</p><p>    <strong>OR</strong> </p><p><strong>range:</strong> 45678</p>         |
| Special Character    | <p><strong>index:</strong> <abc@domain.com>;4 </p><p>                         <strong>OR</strong></p><p><strong>range:</strong> <abc@domain.com>;3-10 </p> | <p><strong>index:</strong> domain.com</p><p>    <strong>OR</strong> </p><p><strong>range:</strong> @domain</p> |
| Alphanumeric strings | <p><strong>index:</strong> ID2025;4  </p><p>                         <strong>OR</strong></p><p><strong>range:</strong> ID2025;3-6</p>                      | <p><strong>index:</strong> 25</p><p> <strong>OR</strong> </p><p><strong>range:</strong> 025</p>                |


---

# 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://docs.avoautomation.com/avo-assure/actions/generic/string-operations/get-sub-string.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.
