”;
Description
Less supports some of the string functions as listed below −
- escape
- e
- % format
- replace
The following table describes the above string functions along with description.
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 −
|
replace("Welcome, val?", "val?", "to Tutorialspoint!");
It replaces the string as −
"Welcome, to Tutorialspoint!"
|
”;