Less支持下面列出的一些字符串函数 :
逃离
e
%format
replace
下表描述了上述字符串函数以及描述.
Sr.No. | 类型&说明 | 示例 |
---|---|---|
1 | Escape 它使用特殊的URL编码对字符串或信息进行编码字符.您无法对某些字符进行编码,例如,,/,?, @ ,& , + ,〜,!, $ ,'和一些您可以编码的字符,例如 \ ,#, ^ ,(,), {,} ,:,> ,< ,] , [和 = . | escape("Hello!! welcome to Tutorialspoint!") 输出转义字符串为 : Hello%21%21%20welcome%20to%20Tutorialspoint%21 |
2 | e 这是一个字符串函数,它使用字符串作为参数并返回没有引号的信息.这是一个CSS转义,它使用〜"some content"转义值和数字作为参数. | filter: e("Hello!! welcome to Tutorialspoint!"); 它输出转义字符串为 : filter: Hello!! welcome to Tutorialspoint!; |
3 | %format 此函数格式化字符串.它可以用以下格式编写 : %(字符串,参数...) | format-a-d: %("myvalues: %a myfile: %d", 2 + 3, "mydir/less_demo.less"); 它输出格式化的字符串为 : format-a-d: "myvalues: 5 myfile: "mydir/less_demo.less""; |
4 | replace 它用于替换字符串中的文本.它使用了一些参数 :
| replace("Welcome, val?", "val\?", "to Tutorialspoint!"); 它将字符串替换为 : "Welcome, to Tutorialspoint!" |