Sass str-index() Function

Last Updated:

Sass str-index() Function

The str-index() function returns the first index of a substring in a string, or null if a string doesn't contain a substring.

Example

SASS TO CSS CONVERTER
//Check your console @debug str-index("sans-serif", "ans"); // 2 @debug str-index("sans-serif", "rif"); // 8

Syntax

str-index($string, $substring)

Parameter Value

ValueTypeExplanation
$string Required A string.
$substring Required A substring.

Return Value

ValueExplanation
Number Returns the first index of $substring in $string, or null if $string doesn’t contain $substring.

Share this Page

Meet the Author