Language Features
- Less - Parent Selectors
- Less - Merge
- Less - Loops
- Less - CSS Guards
- Less - Mixin Guards
- Less - Import Options
- Less - Import Directives
- Less - Passing Rulesets to Mixins
- Less - Mixins as Functions
- Less - Parametric Mixins
- Less - Mixins
- Less - Extend
- Less - Variables
- Less - Importing
- Less - Comments
- Less - Scope
- Less - Namespaces and Accessors
- Less - Functions
- Less - Escaping
- Less - Operations
- Less - Nested Directives and Bubbling
- Less - Nested Rules
Functions
- Less - Color Blending Functions
- Less - Color Operation
- Less - Color Channel Functions
- Less - Color Defination Functions
- Less - Type Functions
- Less - Math Functions
- Less - List Functions
- Less - String Functions
- Less - Misc Functions
Usage
- Less - Frameworks
- Less - Third Party Compilers
- Less - Editors and Plugins
- Less - GUIs
- Less - Online Compilers
- Less - Programmatic Usage
- Less - Plugins
- Less - Browser support
- Using Less In The Browser
- Less - Command Line Usage
Less Useful Resources
Selected Reading
- Who is Who
- Computer Glossary
- HR Interview Questions
- Effective Resume Writing
- Questions and Answers
- UPSC IAS Exams Notes
LESS - String Functions
Description
Less supports some of the string functions as psted 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 − 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!" |