# Извлечение чисел из строки (str\_extract\_numbers)

## str\_extract\_numbers

Функция ищет в тексте все числа и возвращает их в том порядке, в котором они встречаются в строке.

{% hint style="info" %}
В отличие от [str\_extract\_digits](/funkcii/izvlechenie-cifr-iz-stroki-str_extract_digits.md), здесь извлекаются числа, а не цифры.
{% endhint %}

Формат записи следующий:

`[str_extract_numbers]текст\[/str_extract_numbers]`

**Пример использования:**

```
[str_extract_numbers]asdsad12 3 sjd5wef 0 ----2 5.45[/str_extract_numbers]
```

Результат:\
`[12, 3, 5, 0, -2, 5.45]`

#### Аргументы

Функция принимает **1 аргумент**:

1. **Текст (обязательный)**\
   Строка, в которой нужно найти все числа.\
   Из строки будут извлечены:

   * целые числа: `0`, `3`, `12`, `-2`
   * дробные числа с точкой: `5.45`
   * как положительные, так и отрицательные значения

   Числа выводятся в массиве **в том порядке**, в котором они встретились в исходной строке.

**Примеры:**

| Вход                                                                | Результат            |
| ------------------------------------------------------------------- | -------------------- |
| `[str_extract_numbers]abc123def[/str_extract_numbers]`              | `[123]`              |
| `[str_extract_numbers]-1 0 25[/str_extract_numbers]`                | `[-1, 0, 25]`        |
| `[str_extract_numbers]Цена 5.5 и скидка 1.25[/str_extract_numbers]` | `[5.5, 1.25]`        |
| `[str_extract_numbers]тут нет чисел [/str_extract_numbers]`         | `[]` (пустой массив) |

#### Особенности работы

* Дробные числа распознаются **только с точкой**: `5.45`.\
  Запись вида `5,45` числом не считается.

Если возникли вопросы или трудности - смело обращайся в техподдержку. \
Рады каждому, поможем с любым вопросом и решим любую проблему 🤗

{% content-ref url="/pages/-MasAPNcg291uNezFqb4" %}
[Как задать вопрос в поддержку?](/kak-zadat-vopros-v-podderzhku.md)
{% endcontent-ref %}


---

# 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.leadconverter.su/funkcii/izvlechenie-chisel-iz-stroki-str_extract_numbers.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.
