SASS string functions are quite similar to the string functions of any other programming language with only a single difference i.e. the SASS strings use 1 based indexing. It means the first character of the SASS string is stored at index 1 (not 0).
We have created a table that contains the list of all SASS functions with a brief description and examples.
1. quote($string) Function: This function adds the quotes to the unquoted string and returns the quoted string.
"GeeksforGeeks"
2. 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.
CSS
str-index( "Geeksforgeeks" , "G" );
|
1
3. str-insert($string, $insert, $index) Function: This function returns a copy of given string with inserted string at given index.
CSS
str-insert( "forGeeks" , "Geeks" , 0 );
|
"GeeksforGeeks"
4. str-length($string) Function: This function returns the number of characters present in the given string.
CSS
str-length( "GeeksforGeeks" );
|
13
5. str-slice($string, $start-at, $end-at: -1) Function: This function returns the slice of string between the start and end index (both inclusive).
CSS
str-slice( "GeeksforGeeks" , 8 );
str-slice( "GeeksforGeeks" , 6 , 8 );
|
"Geeks"
for
6. to-upper-case($string) Function: This function returns a copy of given string with the ASCII letters converted into upper case.
CSS
to-upper-case( "geeksforgeeks" );
|
"GEEKSFORGEEKS"
7. to-lower-case($string) Function: This function returns a copy of given string with the ASCII letters converted into lower case.
CSS
to-lower-case( "GEEKSFORGEEKS" )
|
"geeksforgeeks"
8. unique-id() Function: This function returns a randomly-generated unquoted string that is a valid CSS identifier.
Randomly Generated ID
9. unquote($string) Function: This function returns the quoted string in unquoted format.
GeeksforGeeks
Last Updated :
08 Jun, 2022
Like Article
Save Article
Share your thoughts in the comments
Please Login to comment...