Skip to content

字符串

一份参考文档,列出了支持字符串表达式中数据转换的内置便利函数。

表达式中的 JavaScript

您可以在表达式中使用任何 JavaScript。有关更多信息,请参阅表达式

base64Encode():base64编码的字符串。

Encode a string as base64.

base64Decode():一个纯字符串。

Convert a base64 encoded string to a normal string.

extractDomain(): 字符串

Extracts a domain from a string containing a valid URL. Returns undefined if none is found.

extractEmail(): 字符串

Extracts an email from a string. Returns undefined if none is found.

extractUrl(): 字符串

Extracts a URL from a string. Returns undefined if none is found.

extractUrlPath(): 字符串

Extract the path but not the root domain from a URL. For example, "https://example.com/orders/1/details".extractUrlPath() returns "/orders/1/details/".

hash(algo?:算法):字符串

Returns a string hashed with the given algorithm.

函数参数

algoOptionalString enum

使用哪种散列算法。

默认:

以下之一: ,,,,,,,,,​​​​​


isDomain(): 布尔值

Checks if a string is a domain.

isEmail():布尔值

Checks if a string is an email.

isEmpty(): 布尔值

Checks if a string is empty.

isNotEmpty(): 布尔值

Checks if a string has content.

isNumeric(): 布尔值

Checks if a string only contains digits.

isUrl(): 布尔值

Checks if a string is a valid URL.

parseJson(): 对象

Equivalent of JSON.parse(). Parses a string as a JSON object.

引用(标记?:字符串):字符串

Returns a string wrapped in the quotation marks. Default quotation is ".

函数参数

markOptionalString

使用哪种引号样式。

默认:


removeMarkdown(): 字符串

Removes Markdown formatting from a string.

replaceSpecialChars(): 字符串

Replaces non-ASCII characters in a string with an ASCII representation.

removeTags(): 字符串

Remove tags, such as HTML or XML, from a string.

toBoolean():布尔值

Convert a string to a boolean. "false", "0", "", and "no" convert to false.

toDateTime():日期

Converts a string to a Luxon date object.

toDecimalNumber(): 数字

See toFloat

toFloat(): 数字

Converts a string to a decimal number.

toInt(): 数字

Converts a string to an integer.

toSentenceCase(): 字符串

Formats a string to sentence case.

toSnakeCase(): 字符串

Formats a string to snake case.

toTitleCase(): 字符串

Formats a string to title case. Will not change already uppercase letters to prevent losing information from acronyms and trademarks such as iPhone or FAANG.

toWholeNumber(): 数字

Converts a string to a whole number.

urlDecode(entireString?:布尔值):字符串

Decodes a URL-encoded string. It decodes any percent-encoded characters in the input string, and replaces them with their original characters.

函数参数

entireStringOptionalBoolean

是否解码属于 URI 语法一部分的字符 (true) 或不解码 (false)。


urlEncode(整个字符串?:布尔值):字符串

Encodes a string to be used/included in a URL.

函数参数

entireStringOptionalBoolean

是否对属于 URI 语法一部分的字符进行编码 (true) 或不编码 (false)。