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.

  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



CSS