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!" |