Curriculum
Course: Sass Functions
Login
Text lesson

Sass String Functions

In Sass, strings are indexed starting from 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 applies quotation marks to an unquoted string and outputs the string with quotes.

  • Example:

quote(GeeksforGeeks);

  • Output: 
"GeeksforGeeks"

2. str-index($string, $substring) Function: 

This function retrieves the index of the first occurrence of a substring within a specified string. If the substring is not found, it returns null.

  • Example: 

str-index(“Geeksforgeeks”, “G”);

  • Output: 
1

3. str-insert($string, $insert, $index) Function: 

This function provides a duplicated version of the provided string with a string inserted at a specified index.

  • Example: 

str-insert(“forGeeks”, “Geeks”, 0);

  • Output: 
"GeeksforGeeks"

4. str-length($string) Function: 

This function calculates and returns the count of characters within the provided string.

  • Example: 

str-length(“GeeksforGeeks”);

  • Output: 
13

5. str-slice($string, $start-at, $end-at: -1) Function:

This function retrieves a portion of the string between the specified start and end indices, including both indices.

  • Example: 

str-slice(“GeeksforGeeks”, 8);

str-slice(“GeeksforGeeks”, 6, 8);

  • Output: 
"Geeks"

6. to-upper-case($string) Function: 

This function generates a duplicate of the provided string, with all ASCII letters converted to uppercase.

  • Example: 

to-upper-case(“geeksforgeeks”);

  • Output: 
"GEEKSFORGEEKS"

7. to-lower-case($string) Function: 

This function creates a duplicate of the given string with all ASCII letters converted to lowercase.

  • Example: 

to_lower_case(“geeksforgeeks!”)

  • Output: 
"geeksforgeeks"

8. unique-id() Function:

This function generates a random unquoted string that conforms to the rules of a valid CSS identifier.

 

  • Example: 

unique-id();

  • Output: 
andomly Generated ID

9. unquote($string) Function:

This function returns the unquoted version of a quoted string.

  • Example: 

unquote("GeeksforGeeks")

  • Output: 
GeeksforGeeks