New We are sorting MAX channels into categories and territories. Read the news

Проверка того, содержит ли строка заданную подстроку



Простая проверка типа «да — нет»
- Метод String.includes():

const searchString = 'infinitely';
const fullText = 'I know not where I was born, save that the castle was' + ' infinitely old and infinitely horrible.';
if (fullText.includes(searchString)) {
    // Подстрока найдена
}

Метод includes() не предоставляет информацию о том, где именно найдено совпадение. Для получения этой информации можно вместо includes() использовать метод String.indexOf()
Views: 7
Open in MAX Report an inaccuracy

Report an inaccuracy

Describe what needs fixing. If you have a source, add a link.

You are leaving datool.ru

The link leads to an external website. datool.ru is not responsible for its content — check the address before entering passwords or payment details.

Redirecting in 10 s

Go