Sass String function


Release date:2024-02-29 Update date:2024-02-29 Editor:admin View counts:107

Label:

Sass String function

Sass String the (string) function is used to process strings and get relevant information.

The starting index value of the Sass string starts at 1, and remember that it is not 0.

The following table lists the string functions for Sass:

Function

Description & example

Quote (string)

Add quotation marks to the string.

Example:

Quote (runoob)

Result: “runoob”

Str-index (string, substring)

Returns the position where the substring substring first appears in the string. Returns null if there is no match to the substring.

Str-index (abcd, a) = > 1

Str-index (abcd, ab) = > 1

Str-index (abcd, X) = > null

Str-index (abcd, c) = > 3

Str-insert (string, insert, index)

Insert insert in the index position in the string string.

Example:

Str-insert (“Hello world!”, “runoob”, 6)

The result: “Hello runoob world!”

Str-length (string)

Returns the length of the string.

Example:

Str-length (“runoob”)

Results: 6

Str-slice (string, start, end)

The substring is intercepted from string, and the start and end position is set by start-at and end-at. If the end index value is not specified, it is intercepted to the end of the string by default.

Str-slice (abcd, 2,3) = > “bc”

Str-slice (“abcd”, 2) = > “bcd”

Str-slice (“abcd”,-3,-2) = > “bc”

Str-slice (“abcd”, 2-2) = > “bc”

To-lower-case (string)

Convert a string to lowercase

Example:

To-lower-case (“RUNOOB”)

Result: “runoob”

To-upper-case (string)

Convert a string to uppercase

Example:

To-upper-case (“runoob”)

Result: “RUNOOB”

Unique-id ()

Returns a random string without quotation marks as an id. However, it can only be guaranteed to ensure the uniqueness of this id in a single Sass compilation.

Example:

Unique-id ()

Result: uad053b1c

Unquote (string)

Remove quotation marks from a string

Example:

Unquote (“runoob”)

Results: runoob

Powered by TorCMS (https://github.com/bukun/TorCMS).