unquote($string)
unquote($string)
: 移除一个字符串里的引号,当然包括双引号以及单引号。如果字符串没有引号,则返回其本身。
unquote("foo") => foo
unquote(foo) => foo
quote($string)
quote($string)
: 给一个字符串添加引号,如果这字符串是用了引号的形式,则返回其本身。
quote("foo") => "foo"
quote(foo) => "foo"
str-length($string)
str-length($string)
: 返回字符串中字符的个数.
str-length("foo") => 3
str-insert($string, $insert, $index)
str-insert($string, $insert, $index): 在字符串$string
中 $index
位置插入$insert
。
注意,在Sass
里,索引开始的数值为1
。
str-insert("abcd", "X", 1) => "Xabcd"
str-insert("abcd", "X", 4) => "abcXd"
str-insert("abcd", "X", 5) => "abcdX"
str-index($string, $substring)
str-index($string, $substring)
: 返回$substring
子字符串第一次在$string
中出现的位置。如果没有匹配到子字符串,则返回null
。
str-index(abcd, a) => 1
str-index(abcd, ab) => 1
str-index(abcd, X) => null
str-index(abcd, c) => 3
str-slice($string, $start-at, [$end-at])
str-slice($string, $start-at, [$end-at])
: 从$string
里提取出子字符串。子字符串从$start-at
索引开始到$end-at
索引位置结束。包含$start-at
和$end-at
,如果省略$end-at
则一直提取到字符串结束。
str-slice("abcd", 2, 3) => "bc"
str-slice("abcd", 2) => "bcd"
str-slice("abcd", -3, -2) => "bc"
str-slice("abcd", 2, -2) => "bc"
to-upper-case($string)
to-upper-case($string)
: 将字符串转换为大写。
to-lower-case($string)
to-lower-case($string)
: 将字符串转换为小写。