Movatterモバイル変換


[0]ホーム

URL:


codecamp

Less 字符串函数

描述

本节将介绍 Less 字符串函数。

Less支持以下列出的一些字符串函数:

  • 逃逸

  • e

  • %格式

  • 更换

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

S.N.类型及描述例子
1Escape

它通过对特殊字符使用URL编码来对字符串或信息进行编码。您无法编码一些字符,例如 / @& + $\'和您可以编码的一些字符,例如 \\#> ^() {}:>,>] [ =
  
  escape("Hello!! welcome to Tutorialspoint!")

它输出转义字符串为:

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

它是一个字符串函数,它使用string作为参数,并返回不带引号的信息。它是一个CSS转义,它使用〜“一些内容"转义的值和数字作为参数。
  filter: e("Hello!! welcome to Tutorialspoint!");

它输出转义字符串为:

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

此函数格式化一个字符串。它可以写成以下格式:
  
 %(string,arguments ...)   
   
format-a-d: %("myvalues: %a myfile: %d", 2 + 3, "mydir/less_demo.less");

它输出格式化的字符串为:

format-a-d: "myvalues: 5 myfile: "mydir/less_demo.less"";
4replace
它用于替换字符串中的文本。 它使用一些参数:
  • string:它搜索字符串并替换。

  • pattern:它搜索正则表达式模式。

  • replacement:它替换与模式匹配的字符串。

  • flags:这些是可选的正则表达式标志。

  replace("Welcome, val?", "val\?", "to Tutorialspoint!");

它将字符串替换为:

  "Welcome, to Tutorialspoint!"

Less 其他函数
Less 列表函数
温馨提示
下载编程狮App,免费阅读超1000+编程语言教程
取消
确定
目录

Less 基本教程

Less 语言特性

Less 函数

Less 用法

关闭

MIP.setData({'pageTheme' : getCookie('pageTheme') || {'day':true, 'night':false},'pageFontSize' : getCookie('pageFontSize') || 20});MIP.watch('pageTheme', function(newValue){setCookie('pageTheme', JSON.stringify(newValue))});MIP.watch('pageFontSize', function(newValue){setCookie('pageFontSize', newValue)});function setCookie(name, value){var days = 1;var exp = new Date();exp.setTime(exp.getTime() + days*24*60*60*1000);document.cookie = name + '=' + value + ';expires=' + exp.toUTCString();}function getCookie(name){var reg = new RegExp('(^| )' + name + '=([^;]*)(;|$)');return document.cookie.match(reg) ? JSON.parse(document.cookie.match(reg)[2]) : null;}
[8]ページ先頭

©2009-2025 Movatter.jp