Skip to main content

includes ()

Determines whether a string includes the characters of a specified substring, returning true or false as appropriate.

Parameters

$string
The source string in which the substring is to be located.
Type
String
$substring
The substring to locate in the source string.
Type
String
$start-at
The index at which to begin the search. A negative index can be used, indicating an offset from the end of the source string.
Type
Number
Default
1

Return Value

Boolean
true if the substring is found anywhere within the given string; otherwise, false.

Example

@use '@sass-fairy/string';

$sentence: 'The quick brown fox jumps over the lazy dog.';

@debug string.includes($sentence, 'quick');
// true

@debug string.includes($sentence, 'quick', 6);
// false

@debug string.includes($sentence, 'dog', -4);
// true