📜  LESS-字符串函数

📅  最后修改于: 2020-10-22 07:13:21             🧑  作者: Mango


 

描述

Less支持以下一些字符串函数-

  • 逃逸
  • Ë
  • %格式
  • 更换

下表描述了上述字符串函数及其说明。

Sr.No. Types & Description Example
1 Escape

It encodes a string or information by using URL encoding on special characters. You could not encode some characters such as , , / , ? , @ , & , + , ~ , ! , $ , and some characters you can encode such as \ , # , ^ , ( , ) , { , } , : , > , < , ] , [ and =.

escape("Hello!! welcome to Tutorialspoint!")

It outputs escaped string as −

Hello%21%21%20welcome%20to%20Tutorialspoint%21
2 e

It is a string function which uses string as parameter and returns the information without quotes. It is a CSS escaping which uses ~”some content” escaped values and numbers as parameters.

filter: e("Hello!! welcome to Tutorialspoint!");

It outputs escaped string as −

filter: Hello!! welcome to Tutorialspoint!;
3 % format

This function formats a string. It can be written with the following format −

%(string, arguments ...)
format-a-d: %("myvalues: %a myfile: %d", 2 + 3, "mydir/less_demo.less");

It outputs the formatted string as −

format-a-d: "myvalues: 5 myfile: "mydir/less_demo.less"";
4 replace

It is used to replace the text within a string. It uses some parameters −

  • string − It searches the string and replace in.
  • pattern − It searches the regular expression pattern.
  • replacement − It replaces the string that matches the pattern.
  • flags − These are optional regular expression flags.
replace("Welcome, val?", "val\?", "to Tutorialspoint!");

It replaces the string as −

"Welcome, to Tutorialspoint!"