# Mid

This is a pre-built Action located under the **@Generic Element**. The functionality of this Action in Avo Assure is to extract the middle character from the given input text. The extracted character is stored in a dynamic variable.

## **Syntax**

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

{% hint style="info" %}
**Note**: If the input string is provided in even number of characters, then it returns the mid+1 \[(length/2) + 1] value.
{% endhint %}

| Argument                          | Description                                                           |
| --------------------------------- | --------------------------------------------------------------------- |
| <p>\<string></p><p>(Required)</p> | Provide the string from which the middle character will be extracted. |

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

| Argument                                     | Description                                                       |
| -------------------------------------------- | ----------------------------------------------------------------- |
| <p>\<Dynamic Variable></p><p>(Required)</p>  | This dynamic variable holds the extracted middle character.       |
| <p>\<Dynamic Variable></p><p>(Optional) </p> | This dynamic variable stores the status as **True** or **False**. |

### **Example 1: Extracting the Middle Characters from a String**

In this example, we explain how to extract the middle portion of a string using.

* **Action**: Mid
* **Input Value**: Michael Brown
  * This specifies the string from which the middle character is extracted
* **Output Value**: {Mid String}
  * The extracted middle portion of the string (l) is stored in this **{Mid 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 middle character is successfully extracted.
    * **False**: If the extraction fails due to invalid input or configuration.
* **Logical Explanation**: The **Mid** action fetches the value from the **Input Value** column (**Michael Brown**) and extracts the middle character from the string which is (l). The extracted middle portion is stored in the **{Mid String}** variable.

<figure><img src="/files/9HQvJmzKv0apbaGIkIpH" alt=""><figcaption></figcaption></figure>

### **Example 2:** Extracting the Middle Character from an Even-Length String

In this example, we explain how to extract the middle character from an even-length string.

* **Action**: Mid
* **Input Value**: Emma
  * This specifies the string from which the middle character is extracted.
* **Output Value**: {Mid String}
  * The extracted middle character (m) is stored in this **{Mid 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 middle character is successfully extracted.
    * **False**: If the extraction fails due to invalid input or configuration.
* **Logical Explanation**: The **Mid** action fetches the string from the **Input Value** column (**Emma**) and identifies the middle position. Since the string has an even number of characters (4), the action extracts the character at the mid + 1 position.

**Process:**

* **String Length** = 4
* **Middle (String Length/2)** = 4 ÷ 2 = 2
* **mid + 1** = 2 + 1 = 3 → Character at position 3 is **“m”**

The extracted middle portion (m) is stored in the **{Mid String}** variable.

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

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

Here are some examples of different string scenarios:

| String               | Input Value      | Result |
| -------------------- | ---------------- | ------ |
| Text Strings         | Automation       | a      |
| Numeric Strings      | 123456           | 4      |
| Special Character    | <abc@domain.com> | a      |
| Alphanumeric strings | ID2025           | 0      |
| Even-Length String   | User             | e      |


---

# 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/mid.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.
