Skip to content

containsAny

Checks if a string contains any of the given substrings.

containsAny

Signature

typescript
function containsAny(str: string, searches: string[], caseSensitive?: boolean): boolean

Parameters

  • str - The string to search in
  • searches - Array of substrings to search for
  • caseSensitive - Whether to perform case-sensitive search (default: true)

Returns

true if any substring is found, false otherwise.

Examples

typescript
import { containsAny } from 'strio'

containsAny('hello world', ['hello', 'foo'])
// true

containsAny('hello world', ['foo', 'bar'])
// false

containsAny('Hello World', ['hello', 'world'], false)
// true

See Also

Released under the MIT License.