starts-with ()
Determines whether a string begins with the characters of a specified substring, returning true or false as appropriate.
Parameters
$string
- The source string in which the substring is to be searched for.
- Type
String
$substring
- The characters to be searched for at the start of 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 given characters are found at the beginning of the string; otherwise,false
.
Example
@use '@sass-fairy/string';
$todo: 'Friday Dinner with Diane.';
@debug string.starts-with($todo, 'Fri');
// true
@debug string.starts-with($todo, 'Di', 8);
// true
@debug string.starts-with($todo, 'Di', -6);
// true