# Working with expressions

{% hint style="danger" %}
Please note that the execution time of a regular expression is 5 seconds.
{% endhint %}

findall() | similar()

<mark style="color:red;">**LEGEND:**</mark>

<mark style="color:red;">**!**</mark> - Required parameters

#### <mark style="background-color:blue;">Search in a string using a regular expression</mark>

**findall(reg, str, index) -** to find all group matches in a string

Parameters:

<mark style="color:red;">**!**</mark>**&#x20;reg** - regular expression

<mark style="color:red;">**!**</mark>**&#x20;str** -  string in which search is performed

&#x20;**index** - index of found result. It starts at zero. That means the first found result has index 0.

<mark style="background-color:blue;">**String comparison with typo tolerance**</mark>

**similar(str1, str2)** - compares two strings allowing for typos. Returns True if the strings differ by less than 30%.

<details>

<summary>Example</summary>

Let’s look at an example of searching for a string using a specified regular expression:

<div data-with-frame="true"><figure><img src="/files/eIQelwOEWa6lfysRcEc6" alt="" width="375"><figcaption></figcaption></figure></div>

The result is the following:

<div data-with-frame="true"><figure><img src="/files/t54orputypE0R4SqBD8w" alt="" width="375"><figcaption></figcaption></figure></div>

Example of using the typo-tolerant string comparison function:&#x20;

In the start block, we add our riddle in the message section. Then, we also add the answer to our riddle in the calculator using the variable:

**riddle = 'cold'.**

In the second block, we enter the following expression into the calculator:

**response = if(similar(riddle, question) == True, "super!", "Nooo! it's a #{riddle}").**

Don’t forget to add **#{response}** to the message section.

<div data-with-frame="true"><figure><img src="/files/bWNII688hdfyokdqi2hj" alt="" width="375"><figcaption></figcaption></figure></div>

<div data-with-frame="true"><figure><img src="/files/TBVYxlG7UQdJANTtFcDm" alt=""><figcaption></figcaption></figure></div>

<div data-with-frame="true"><figure><img src="/files/CMDCcR72xPd2emUrRpay" alt="" width="375"><figcaption></figcaption></figure></div>

</details>

<details>

<summary>Code</summary>

<pre><code><strong>a = findall('.ai\/(.+)\/', 'https://payform.com/ab252acn/', 0)
</strong>
response = if(similar(riddle, question) == True , "super!", "Nooo! it's a #{riddle}")
</code></pre>

</details>


---

# 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.mavibot.ai/chatbot/functions/calculator/expressions.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.
