SASS | Строковые функции
Опубликовано: 2 Марта, 2022
Строковые функции SASS очень похожи на строковые функции любого другого языка программирования с одним отличием, то есть строки SASS используют индексирование на основе 1. Это означает, что первый символ строки SASS хранится с индексом 1 (не 0).
We have created a table that contains the list of all SASS functions with a brief description and examples.
- quote($string) Function: This function adds the quotes to the unquoted string and returns the quoted string.
- Example:
quote(GeeksforGeeks);
- Output:
"GeeksforGeeks"
- Example:
- str-index($string, $substring) Function: This function returns the index of first occurrence of the substring in a given string. If the string does not contain substring then it returns null.
- Example:
str-index(
"Geeksforgeeks"
,
"G"
);
- Output:
1
- Example:
- str-insert($string, $insert, $index) Function: This function returns a copy of given string with inserted string at given index.
- Example:
str-insert(
"forGeeks"
,
"Geeks"
,
0
);
- Output:
"GeeksforGeeks"
- Example:
- str-length($string) Function: This function returns the number of characters preent in the given string.
- Example:
str-length(
"GeeksforGeeks"
);
- Output:
13
- Example:
- str-slice($string, $start-at, $end-at: -1) Function: This function returns the slice of string between the strart and end index (both inclusive).
- Example:
str-slice(
"GeeksforGeeks"
,
8
);
str-slice(
"GeeksforGeeks"
,
6
,
8
);
- Output:
"Geeks" for
- Example:
- to-upper-case($string) Function: This function returns a copy of given string with the ASCII letters converted into upper case.
- Example:
to-upper-case(
"geeksforgeeks"
);
- Output:
"GEEKSFORGEEKS"
- Example:
- to-lower-case($string) Function: This function returns a copy of given string with the ASCII letters converted into lower case.
- Example:
to-lower-case(
"GEEKSFORGEEKS"
)
- Output:
"geeksforgeeks"
- Example:
- unique-id() Function: This function returns a randomly-generated unquoted string that is a valid CSS identifier.
- Example:
unique-id();
- Output:
Randomely Generated ID
- Example:
- unquote($string) Function: This function returns the quoted string in unquoted format.
- Example:
unquote(
"GeeksforGeeks"
)
- Output:
GeeksforGeeks
- Example: