Kebab file names

This commit is contained in:
Angelos Chalaris
2023-04-27 21:58:35 +03:00
parent 1d189c709a
commit 61200d90c4
440 changed files with 0 additions and 0 deletions

View File

@ -0,0 +1,21 @@
---
title: Case-insensitive substring search
tags: string
author: chalarangelo
cover: cup-of-orange
firstSeen: 2022-07-28T05:00:00-04:00
---
Checks if a string contains a substring, case-insensitive.
- Use the `RegExp` constructor with the `'i'` flag to create a regular expression, that matches the given `searchString`, ignoring the case.
- Use `RegExp.prototype.test()` to check if the string contains the substring.
```js
const includesCaseInsensitive = (str, searchString) =>
new RegExp(searchString, 'i').test(str);
```
```js
includesCaseInsensitive('Blue Whale', 'blue'); // true
```