string

Functions group for work with strings.

str-capitalize

Capitalizes a given string.

Arguments:

NameTypeDefaultDescription
$string *stringThe input string.

Returns:

string - The input string with its first character transformed to uppercase.

Example:

@use 'more-sass' as more;

@debug more.str-capitalize('foo bar'); // string: 'Foo bar'

str-replace

Replaces all occurrences of the search string with the replacement string.

Arguments:

NameTypeDefaultDescription
$string *stringThe string being searched and replaced on.
$search *stringThe value being searched for.
$replace *stringThe replacement value that replaces found search values.
$limit?numbernullIf supplied, this will be set to the number of replacements performed.

Returns:

string - The string with searched values replaced.

Example:

@use 'more-sass' as more;

@debug more.str-replace('foo bar baz', 'ba', 'x'); // string: 'foo xr xz'

str-split

Splits a given string to a list of strings.

Arguments:

NameTypeDefaultDescription
$string *stringThe input string.
$delimiterstring''The boundary string.
$separatorstringautoThe output list separator
space | comma | slash | auto

Returns:

list - The list containing strings created by splitting the input string by boundary string.

Example:

@use 'more-sass' as more;

@debug more.str-split('foo|bar|baz', '|', 'comma'); // list: ('foo', 'bar', 'baz')

str-trim

Removes whitespaces from both ends of a given string.

Arguments:

NameTypeDefaultDescription
$string *stringThe string to trim.

Returns:

string - The string without whitespaces on both ends of it.

Example:

@use 'more-sass' as more;

@debug more.str-trim(' foo bar   '); // string: 'foo bar'
Edit this page on GitHub Updated at Mon, Jan 30, 2023