Skip to content
Related Articles

Related Articles

Improve Article
SASS | String Functions
  • Last Updated : 06 May, 2020

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 uses 1 based indexing. It means the first character of the SASS string 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.
    • Example:




      quote(GeeksforGeeks);
    • Output:
      "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.
    • Example:




      str-index("Geeksforgeeks", "G");
    • Output:
      1
  3. 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"
  4. str-length($string) Function: This function returns the number of characters preent in the given string.
    • Example:




      str-length("GeeksforGeeks");
    • Output:
      13
  5. 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
  6. 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"
  7. 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"
  8. unique-id() Function: This function returns a randomly-generated unquoted string that is a valid CSS identifier.
    • Example:




      unique-id();
    • Output:
      Randomely Generated ID
  9. unquote($string) Function: This function returns the quoted string in unquoted format.
    • Example:




      unquote("GeeksforGeeks")
    • Output:
      GeeksforGeeks



My Personal Notes arrow_drop_up
Recommended Articles
Page :