Sass String Func
# Sass String Functions
[ Sass Functions](#)
Sass String functions are used to process strings and get related information.
The starting index value of Sass strings starts from 1, remember not 0.
The following table lists the Sass string functions:
| Function | Description & Examples |
| --- | --- |
| quote(_string_) | Adds quotes to a string. **Example:** quote(tutorial) Result: "tutorial" |
| str-index(_string_,_substring_) | Returns the position where the substring first appears in the string. Returns null if no match is found. 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_) | Inserts insert into string at position index. **Example:** str-insert("Hello world!", " tutorial", 6) Result: "Hello tutorial world!" |
| str-length(_string_) | Returns the length of the string. **Example:** str-length("tutorial") Result: 6 |
| str-slice(_string_, _start_, _end_) | Extracts a substring from string, setting start and end positions. If end index is not specified, it defaults to the end of the string. 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_) | Converts the string to lowercase **Example:** to-lower-case("TUTORIAL") Result: "tutorial" |
| to-upper-case(_string_) | Converts the string to uppercase **Example:** to-upper-case("tutorial") Result: "TUTORIAL" |
| unique-id() | Returns a random unquoted string as an id. However, it can only guarantee uniqueness of this id within a single Sass compilation. **Example:** unique-id() Result: uad053b1c |
| unquote(_string_) | Removes quotes from a string **Example:** unquote("tutorial") Result: tutorial |
* * Sass Functions](#)
YouTip