经常使用于操做和获取有关字符串的信息,字符串是基于1的,字符串中的第一个字符是位于索引1而不是0。sass
下面是关于全部字符串函数的一个相关整理:函数
quote(string),向字符串添加引号,并返回结果code
quote(Welcome to xkd!) Result: "Welcome to xkd!"
str-index(string , substring),返回字符串中第一个出现的子字符串的索引索引
str-index("Welcome to xkd!", "W") Result: 1
str-insert(string , insert , index),返回指定索引位置插入insert的字符串字符串
str-insert("Welcome to xkd!", " our", 8) Result: "Welcome to our xkd!"
str-length(string),返回字符串的长度(以字符为单位)string
str-length("Hello world!") Result: 12
str-slice(string , strat , end),从字符串中提取字符,从开始处开始到结束处结束,并返回切片io
str-slice("Hello world!", 2, 5) Result: "ello"
to-lower-case(string),返回转换为小写的字符串副本编译
to-lower-case("Welcome to xkd!") Result: "welcome to xkd!"
to-upper-case(string),返回转换为大写的字符串副本引用
to-upper-case("Welcome to xkd!") Result: "WELCOME TO XKD!"
unique-id(),返回一个随机生成的不带引号的惟一的字符串(保证当前sass会话中是惟一的)co
unique-id() Result: afvagfvakj
unquote(string),若是字符周围有引号将移除,并返回结果
unquote("Welcome to xkd!") Result: Welcome to xkd!
注意:在使用 #{}(interpolation)时,有引号字符串将会被编译为无引号字符串,这样便于在 mixin 中引用选择器名。