# Работа с выражениями

{% hint style="danger" %}
Обратите внимание, что время выполнения регулярного выражения составляет 5 секунд.
{% endhint %}

findall() | similar()

<mark style="color:красный;">**ЛЕГЕНДА:**</mark>

<mark style="color:красный;">**!**</mark> - Обязательные параметры

#### <mark style="color:по умолчанию;background-color:blue;">Поиск в строке с помощью регулярного выражения</mark>

**findall(reg, str, index) -** для поиска всех совпадений групп в строке

Параметры:

<mark style="color:красный;">**!**</mark>**&#x20;reg** - регулярное выражение

<mark style="color:красный;">**!**</mark>**&#x20;str** - строка, в которой выполняется поиск

&#x20;**index** - индекс найденного результата. Он начинается с нуля. Это означает, что первый найденный результат имеет индекс 0.

<mark style="color:по умолчанию;background-color:blue;">**Сравнение строк с допуском опечаток**</mark>

**similar(str1, str2)** - сравнивает две строки с учетом опечаток. Возвращает True, если строки отличаются менее чем на 30%.

<details>

<summary>Пример</summary>

Давайте рассмотрим пример поиска строки с помощью указанного регулярного выражения:

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

Результат следующий:

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

Пример использования функции сравнения строк с допуском опечаток:&#x20;

В стартовом блоке мы добавляем нашу загадку в раздел сообщения. Затем мы также добавляем ответ на нашу загадку в калькулятор с помощью переменной:

**riddle = 'cold'.**

Во втором блоке мы вводим в калькулятор следующее выражение:

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

Не забудьте добавить **#{response}** в раздел сообщения.

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

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

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

</details>

<details>

<summary>Код</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/doc/ru/chatbot/functions/kalkulyator/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.
