Azure 数据工厂中的表达式和函数Expressions and functions in Azure Data Factory

适用于:是 Azure 数据工厂是 Azure Synapse Analytics(预览版)APPLIES TO: yesAzure Data Factory yesAzure Synapse Analytics (Preview)

本文提供了有关 Azure 数据工厂支持的表达式和函数的详细信息。This article provides details about expressions and functions supported by Azure Data Factory.

表达式Expressions

定义中的 JSON 值可以是文字,也可以是运行时计算的表达式。JSON values in the definition can be literal or expressions that are evaluated at runtime. 例如:For example:

"name": "value"

or

"name": "@pipeline().parameters.password"

表达式可出现在 JSON 字符串值中的任何位置,始终生成另一个 JSON 值。Expressions can appear anywhere in a JSON string value and always result in another JSON value. 如果某个 JSON 值为表达式,会通过删除 @ 符号来提取表达式的正文。If a JSON value is an expression, the body of the expression is extracted by removing the at-sign (@). 如果需要以“@”开头的文本字符串,则必须使用 @@ 将它转义。If a literal string is needed that starts with @, it must be escaped by using @@. 以下示例演示了如何计算表达式。The following examples show how expressions are evaluated.

JSON 值JSON value 结果Result
"parameters""parameters" 返回字符“parameters”。The characters 'parameters' are returned.
"parameters[1]""parameters[1]" 返回字符“parameters[1]”。The characters 'parameters[1]' are returned.
"@@""@@" 返回包含“@”的、由 1 个字符构成的字符串。A 1 character string that contains '@' is returned.
" @"" @" 返回包含“@”的、由 2 个字符构成的字符串。A 2 character string that contains ' @' is returned.

如果使用称为字符串内插的功能(其中表达式封装在 @{ ... } 内),表达式还可以显示在字符串内。Expressions can also appear inside strings, using a feature called string interpolation where expressions are wrapped in @{ ... }. 例如: "name" : "First Name: @{pipeline().parameters.firstName} Last Name: @{pipeline().parameters.lastName}"For example: "name" : "First Name: @{pipeline().parameters.firstName} Last Name: @{pipeline().parameters.lastName}"

使用字符串内插,结果始终是字符串。Using string interpolation, the result is always a string. 假设我将 myNumber 定义为 42,将 myString 定义为 fooSay I have defined myNumber as 42 and myString as foo:

JSON 值JSON value 结果Result
"@pipeline().parameters.myString""@pipeline().parameters.myString" 返回字符串形式的 fooReturns foo as a string.
"@{pipeline().parameters.myString}""@{pipeline().parameters.myString}" 返回字符串形式的 fooReturns foo as a string.
"@pipeline().parameters.myNumber""@pipeline().parameters.myNumber" 返回数字形式的 42Returns 42 as a number.
"@{pipeline().parameters.myNumber}""@{pipeline().parameters.myNumber}" 返回字符串形式的 42Returns 42 as a string.
"Answer is: @{pipeline().parameters.myNumber}""Answer is: @{pipeline().parameters.myNumber}" 返回字符串 Answer is: 42Returns the string Answer is: 42.
"@concat('Answer is: ', string(pipeline().parameters.myNumber))""@concat('Answer is: ', string(pipeline().parameters.myNumber))" 返回字符串 Answer is: 42Returns the string Answer is: 42
"Answer is: @@{pipeline().parameters.myNumber}""Answer is: @@{pipeline().parameters.myNumber}" 返回字符串 Answer is: @{pipeline().parameters.myNumber}Returns the string Answer is: @{pipeline().parameters.myNumber}.

示例Examples

复杂表达式示例Complex expression example

以下示例显示了一个复杂的示例,该示例引用了活动输出的一个深层子字段。The below example shows a complex example that references a deep sub-field of activity output. 若要引用计算结果为子字段的管道参数,请使用 [] 语法而不是点 (.) 运算符(如 subfield1 和 subfield2 一样)To reference a pipeline parameter that evaluates to a sub-field, use [] syntax instead of dot(.) operator (as in case of subfield1 and subfield2)

@activity('{activityName}').output.{subfield1}.{subfield2}[pipeline().parameters.subfield3].{subfield4}@activity('{activityName}').output.{subfield1}.{subfield2}[pipeline().parameters.subfield3].{subfield4}

使用参数的数据集A dataset with a parameter

在以下示例中,BlobDataset 采用名为 path 的参数。In the following example, the BlobDataset takes a parameter named path. 其值用于使用以下表达式设置 folderPath 属性的值:dataset().pathIts value is used to set a value for the folderPath property by using the expression: dataset().path.

{
    "name": "BlobDataset",
    "properties": {
        "type": "AzureBlob",
        "typeProperties": {
            "folderPath": "@dataset().path"
        },
        "linkedServiceName": {
            "referenceName": "AzureStorageLinkedService",
            "type": "LinkedServiceReference"
        },
        "parameters": {
            "path": {
                "type": "String"
            }
        }
    }
}

使用参数的管道A pipeline with a parameter

在以下示例中,管道采用 inputPathoutputPath 参数。In the following example, the pipeline takes inputPath and outputPath parameters. 参数化 blob 数据集的路径使用这些参数的值进行设置。The path for the parameterized blob dataset is set by using values of these parameters. 此处使用的语法是:pipeline().parameters.parameternameThe syntax used here is: pipeline().parameters.parametername.

{
    "name": "Adfv2QuickStartPipeline",
    "properties": {
        "activities": [
            {
                "name": "CopyFromBlobToBlob",
                "type": "Copy",
                "inputs": [
                    {
                        "referenceName": "BlobDataset",
                        "parameters": {
                            "path": "@pipeline().parameters.inputPath"
                        },
                        "type": "DatasetReference"
                    }
                ],
                "outputs": [
                    {
                        "referenceName": "BlobDataset",
                        "parameters": {
                            "path": "@pipeline().parameters.outputPath"
                        },
                        "type": "DatasetReference"
                    }
                ],
                "typeProperties": {
                    "source": {
                        "type": "BlobSource"
                    },
                    "sink": {
                        "type": "BlobSink"
                    }
                }
            }
        ],
        "parameters": {
            "inputPath": {
                "type": "String"
            },
            "outputPath": {
                "type": "String"
            }
        }
    }
}

教程Tutorial

教程逐步讲解如何在管道和活动之间以及活动之间传递参数。This tutorial walks you through how to pass parameters between a pipeline and activity as well as between the activities.

函数Functions

可以在表达式中调用函数。You can call functions within expressions. 以下各节提供了有关可以在表达式中使用的函数的信息。The following sections provide information about the functions that can be used in an expression.

字符串函数String functions

若要使用字符串,可以使用这些字符串函数以及某些集合函数To work with strings, you can use these string functions and also some collection functions. 字符串函数仅适用于字符串。String functions work only on strings.

字符串函数String function 任务Task
concatconcat 组合两个或更多字符串,并返回组合后的字符串。Combine two or more strings, and return the combined string.
endsWithendsWith 检查字符串是否以指定的子字符串结尾。Check whether a string ends with the specified substring.
guidguid 生成字符串形式的全局唯一标识符 (GUID)。Generate a globally unique identifier (GUID) as a string.
indexOfindexOf 返回子字符串的起始位置。Return the starting position for a substring.
lastIndexOflastIndexOf 返回最后一次出现的子字符串的起始位置。Return the starting position for the last occurrence of a substring.
replacereplace 将子字符串替换为指定的字符串,并返回更新的字符串。Replace a substring with the specified string, and return the updated string.
splitsplit 根据原始字符串中指定的分隔符字符,从较大字符串中返回一个包含子字符串(以逗号分隔)的数组。Return an array that contains substrings, separated by commas, from a larger string based on a specified delimiter character in the original string.
startsWithstartsWith 检查字符串是否以特定的子字符串开头。Check whether a string starts with a specific substring.
substringsubstring 返回字符串中的字符,从指定的位置开始。Return characters from a string, starting from the specified position.
toLowertoLower 返回小写格式的字符串。Return a string in lowercase format.
toUppertoUpper 返回大写格式的字符串。Return a string in uppercase format.
trimtrim 从字符串中删除前导和尾随空格,并返回更新后的字符串。Remove leading and trailing whitespace from a string, and return the updated string.

集合函数Collection functions

若要使用集合(通常是数组或字符串,有时是字典),可以使用这些集合函数。To work with collections, generally arrays, strings, and sometimes, dictionaries, you can use these collection functions.

集合函数Collection function 任务Task
containscontains 检查集合是否包含某个特定项。Check whether a collection has a specific item.
emptyempty 检查集合是否为空。Check whether a collection is empty.
firstfirst 返回集合中的第一个项。Return the first item from a collection.
intersectionintersection 返回其中仅包含指定集合的共有项的一个集合。Return a collection that has only the common items across the specified collections.
joinjoin 返回一个字符串,其中包含某个数组中的所有项并以指定的分隔符分隔每个项。Return a string that has all the items from an array, separated by the specified character.
lastlast 返回集合中的最后一个项。Return the last item from a collection.
lengthlength 返回字符串或数组中的项数。Return the number of items in a string or array.
skipskip 删除集合开头的项,并返回所有其他项。Remove items from the front of a collection, and return all the other items.
taketake 返回集合开头的项。Return items from the front of a collection.
unionunion 返回一个集合,其中包含指定集合中的所有项。Return a collection that has all the items from the specified collections.

逻辑函数Logical functions

这些函数可在条件中使用,并可用于评估任何类型的逻辑。These functions are useful inside conditions, they can be used to evaluate any type of logic.

逻辑比较函数Logical comparison function 任务Task
andand 检查所有表达式是否为 true。Check whether all expressions are true.
equalsequals 检查两个值是否相等。Check whether both values are equivalent.
greatergreater 检查第一个值是否大于第二个值。Check whether the first value is greater than the second value.
greaterOrEqualsgreaterOrEquals 检查第一个值是否大于或等于第二个值。Check whether the first value is greater than or equal to the second value.
ifif 检查表达式为 true 还是 false。Check whether an expression is true or false. 根据结果返回指定的值。Based on the result, return a specified value.
lessless 检查第一个值是否小于第二个值。Check whether the first value is less than the second value.
lessOrEqualslessOrEquals 检查第一个值是否小于或等于第二个值。Check whether the first value is less than or equal to the second value.
notnot 检查表达式是否为 false。Check whether an expression is false.
oror 检查是否至少一个表达式为 true。Check whether at least one expression is true.

转换函数Conversion functions

这些函数用于在语言中的每个本机类型之间转换:These functions are used to convert between each of the native types in the language:

  • stringstring
  • integerinteger
  • floatfloat
  • booleanboolean
  • arraysarrays
  • dictionariesdictionaries
转换函数Conversion function 任务Task
arrayarray 从单个指定的输入返回数组。Return an array from a single specified input. 对于多个输入,请参阅 createArrayFor multiple inputs, see createArray.
base64base64 返回字符串的 base64 编码版本。Return the base64-encoded version for a string.
base64ToBinarybase64ToBinary 返回 base64 编码字符串的二进制版本。Return the binary version for a base64-encoded string.
base64ToStringbase64ToString 返回 base64 编码字符串的字符串版本。Return the string version for a base64-encoded string.
binarybinary 返回输入值的二进制版本。Return the binary version for an input value.
boolbool 返回输入值的布尔值版本。Return the Boolean version for an input value.
coalescecoalesce 返回一个或多个参数中的第一个非 null 值。Return the first non-null value from one or more parameters.
createArraycreateArray 从多个输入返回数组。Return an array from multiple inputs.
dataUridataUri 返回输入值的数据 URI。Return the data URI for an input value.
dataUriToBinarydataUriToBinary 返回数据 URI 的二进制版本。Return the binary version for a data URI.
dataUriToStringdataUriToString 返回数据 URI 的字符串版本。Return the string version for a data URI.
decodeBase64decodeBase64 返回 base64 编码字符串的字符串版本。Return the string version for a base64-encoded string.
decodeDataUridecodeDataUri 返回数据 URI 的二进制版本。Return the binary version for a data URI.
decodeUriComponentdecodeUriComponent 返回一个字符串,并将其中的转义字符替换为解码后的版本。Return a string that replaces escape characters with decoded versions.
encodeUriComponentencodeUriComponent 返回一个字符串,并将其中的 URL 不安全字符替换为转义字符。Return a string that replaces URL-unsafe characters with escape characters.
floatfloat 返回输入值的浮点数。Return a floating point number for an input value.
intint 返回字符串的整数版本。Return the integer version for a string.
jsonjson 返回字符串或 XML 的 JavaScript 对象表示法 (JSON) 类型的值或对象。Return the JavaScript Object Notation (JSON) type value or object for a string or XML.
stringstring 返回输入值的字符串版本。Return the string version for an input value.
uriComponenturiComponent 通过将 URL 不安全字符替换为转义字符来返回输入值的 URI 编码版本。Return the URI-encoded version for an input value by replacing URL-unsafe characters with escape characters.
uriComponentToBinaryuriComponentToBinary 返回 URI 编码字符串的二进制版本。Return the binary version for a URI-encoded string.
uriComponentToStringuriComponentToString 返回 URI 编码字符串的字符串版本。Return the string version for a URI-encoded string.
xmlxml 返回字符串的 XML 版本。Return the XML version for a string.
xpathxpath 检查 XML 中是否存在与 XPath(XML 路径语言)表达式匹配的节点或值,并返回匹配的节点或值。Check XML for nodes or values that match an XPath (XML Path Language) expression, and return the matching nodes or values.

数学函数Math functions

这些函数可用于以下任一数字类型:整数浮点数These functions can be used for either types of numbers: integers and floats.

数学函数Math function 任务Task
addadd 返回两个数字相加的结果。Return the result from adding two numbers.
divdiv 返回两个数字相除的结果。Return the result from dividing two numbers.
maxmax 返回一组数字或数组中的最大值。Return the highest value from a set of numbers or an array.
minmin 返回一组数字或数组中的最小值。Return the lowest value from a set of numbers or an array.
modmod 返回将两个数字相除后的余数。Return the remainder from dividing two numbers.
mulmul 返回将两个数字相乘得到的乘积。Return the product from multiplying two numbers.
randrand 返回指定范围内的随机整数。Return a random integer from a specified range.
rangerange 返回以指定整数开头的一个整数数组。Return an integer array that starts from a specified integer.
subsub 返回第一个数字减去第二个数字得到的结果。Return the result from subtracting the second number from the first number.

日期函数Date functions

日期或时间函数Date or time function 任务Task
addDaysaddDays 将天数加到时间戳。Add a number of days to a timestamp.
addHoursaddHours 将小时数加到时间戳。Add a number of hours to a timestamp.
addMinutesaddMinutes 将分钟数加到时间戳。Add a number of minutes to a timestamp.
addSecondsaddSeconds 将秒数加到时间戳。Add a number of seconds to a timestamp.
addToTimeaddToTime 将一定数目的时间单位加到时间戳。Add a number of time units to a timestamp. 另请参阅 getFutureTimeSee also getFutureTime.
convertFromUtcconvertFromUtc 将时间戳从协调世界时 (UTC) 转换为目标时区。Convert a timestamp from Universal Time Coordinated (UTC) to the target time zone.
convertTimeZoneconvertTimeZone 将时间戳从源时区转换为目标时区。Convert a timestamp from the source time zone to the target time zone.
convertToUtcconvertToUtc 将时间戳从源时区转换为协调世界时 (UTC)。Convert a timestamp from the source time zone to Universal Time Coordinated (UTC).
dayOfMonthdayOfMonth 返回时间戳中月份组成部分的日期。Return the day of the month component from a timestamp.
dayOfWeekdayOfWeek 返回时间戳中周组成部分的星期日期。Return the day of the week component from a timestamp.
dayOfYeardayOfYear 返回时间戳中年组成部分的日期。Return the day of the year component from a timestamp.
formatDateTimeformatDateTime 以可选格式返回字符串形式的时间戳。Return the timestamp as a string in optional format.
getFutureTimegetFutureTime 返回当前时间戳加上指定的时间单位。Return the current timestamp plus the specified time units. 另请参阅 addToTimeSee also addToTime.
getPastTimegetPastTime 返回当前时间戳减去指定的时间单位。Return the current timestamp minus the specified time units. 另请参阅 subtractFromTimeSee also subtractFromTime.
startOfDaystartOfDay 返回时间戳中的天的开始时间。Return the start of the day for a timestamp.
startOfHourstartOfHour 返回时间戳中的小时的开始时间。Return the start of the hour for a timestamp.
startOfMonthstartOfMonth 返回时间戳中的月份的开始时间。Return the start of the month for a timestamp.
subtractFromTimesubtractFromTime 从时间戳中减去一定数目的时间单位。Subtract a number of time units from a timestamp. 另请参阅 getPastTimeSee also getPastTime.
ticksticks 返回指定时间戳的 ticks 属性值。Return the ticks property value for a specified timestamp.
utcNowutcNow 返回字符串形式的当前时间戳。Return the current timestamp as a string.

函数参考Function reference

本部分按字母顺序列出所有可用函数。This section lists all the available functions in alphabetical order.

addadd

返回两个数字相加的结果。Return the result from adding two numbers.

add(<summand_1>, <summand_2>)
参数Parameter 必须Required 类型Type 说明Description
<summand_1>, <summand_2><summand_1>, <summand_2> Yes 整数、浮点数或混合类型Integer, Float, or mixed 要相加的数字The numbers to add
返回值Return value 类型Type 说明Description
<result-sum><result-sum> 整数或浮点数Integer or Float 指定数字相加的结果。The result from adding the specified numbers

示例Example

此示例将指定的数字相加:This example adds the specified numbers:

add(1, 1.5)

并返回以下结果:2.5And returns this result: 2.5

addDaysaddDays

将天数加到时间戳。Add a number of days to a timestamp.

addDays('<timestamp>', <days>, '<format>'?)
参数Parameter 必须Required 类型Type 说明Description
<timestamp><timestamp> Yes StringString 包含时间戳的字符串The string that contains the timestamp
<days><days> Yes IntegerInteger 要加上的正负天数The positive or negative number of days to add
<format><format> No StringString 单一格式的说明符自定义格式的模式Either a single format specifier or a custom format pattern. 时间戳的默认格式为“o”(yyyy-MM-ddT:mm:ss:fffffffK),这符合 ISO 8601 标准并保留了时区信息。The default format for the timestamp is "o" (yyyy-MM-ddTHH:mm:ss:fffffffK), which complies with ISO 8601 and preserves time zone information.
返回值Return value 类型Type 说明Description
<updated-timestamp><updated-timestamp> StringString 时间戳加上指定的天数The timestamp plus the specified number of days

示例 1Example 1

此示例将 10 天加到指定的时间戳:This example adds 10 days to the specified timestamp:

addDays('2018-03-15T13:00:00Z', 10)

并返回以下结果:"2018-03-25T00:00:0000000Z"And returns this result: "2018-03-25T00:00:0000000Z"

示例 2Example 2

此示例从指定的时间戳减去 5 天:This example subtracts five days from the specified timestamp:

addDays('2018-03-15T00:00:00Z', -5)

并返回以下结果:"2018-03-10T00:00:0000000Z"And returns this result: "2018-03-10T00:00:0000000Z"

addHoursaddHours

将小时数加到时间戳。Add a number of hours to a timestamp.

addHours('<timestamp>', <hours>, '<format>'?)
参数Parameter 必须Required 类型Type 说明Description
<timestamp><timestamp> Yes StringString 包含时间戳的字符串The string that contains the timestamp
<hours><hours> Yes IntegerInteger 要加上的正负小时数The positive or negative number of hours to add
<format><format> No StringString 单一格式的说明符自定义格式的模式Either a single format specifier or a custom format pattern. 时间戳的默认格式为“o”(yyyy-MM-ddT:mm:ss:fffffffK),这符合 ISO 8601 标准并保留了时区信息。The default format for the timestamp is "o" (yyyy-MM-ddTHH:mm:ss:fffffffK), which complies with ISO 8601 and preserves time zone information.
返回值Return value 类型Type 说明Description
<updated-timestamp><updated-timestamp> StringString 时间戳加上指定的小时数The timestamp plus the specified number of hours

示例 1Example 1

此示例将 10 小时加到指定的时间戳:This example adds 10 hours to the specified timestamp:

addHours('2018-03-15T00:00:00Z', 10)

并返回以下结果:"2018-03-15T10:00:0000000Z"And returns this result: "2018-03-15T10:00:0000000Z"

示例 2Example 2

此示例从指定的时间戳减去 5 小时:This example subtracts five hours from the specified timestamp:

addHours('2018-03-15T15:00:00Z', -5)

并返回以下结果:"2018-03-15T10:00:0000000Z"And returns this result: "2018-03-15T10:00:0000000Z"

addMinutesaddMinutes

将分钟数加到时间戳。Add a number of minutes to a timestamp.

addMinutes('<timestamp>', <minutes>, '<format>'?)
参数Parameter 必须Required 类型Type 说明Description
<timestamp><timestamp> Yes StringString 包含时间戳的字符串The string that contains the timestamp
<minutes><minutes> Yes IntegerInteger 要加上的正负分钟数The positive or negative number of minutes to add
<format><format> No StringString 单一格式的说明符自定义格式的模式Either a single format specifier or a custom format pattern. 时间戳的默认格式为“o”(yyyy-MM-ddT:mm:ss:fffffffK),这符合 ISO 8601 标准并保留了时区信息。The default format for the timestamp is "o" (yyyy-MM-ddTHH:mm:ss:fffffffK), which complies with ISO 8601 and preserves time zone information.
返回值Return value 类型Type 说明Description
<updated-timestamp><updated-timestamp> StringString 时间戳加上指定的分钟数The timestamp plus the specified number of minutes

示例 1Example 1

此示例将 10 分钟加到指定的时间戳:This example adds 10 minutes to the specified timestamp:

addMinutes('2018-03-15T00:10:00Z', 10)

并返回以下结果:"2018-03-15T00:20:00.0000000Z"And returns this result: "2018-03-15T00:20:00.0000000Z"

示例 2Example 2

此示例从指定的时间戳减去 5 分钟:This example subtracts five minutes from the specified timestamp:

addMinutes('2018-03-15T00:20:00Z', -5)

并返回以下结果:"2018-03-15T00:15:00.0000000Z"And returns this result: "2018-03-15T00:15:00.0000000Z"

addSecondsaddSeconds

将秒数加到时间戳。Add a number of seconds to a timestamp.

addSeconds('<timestamp>', <seconds>, '<format>'?)
参数Parameter 必须Required 类型Type 说明Description
<timestamp><timestamp> Yes StringString 包含时间戳的字符串The string that contains the timestamp
<seconds><seconds> Yes IntegerInteger 要加上的正负秒数The positive or negative number of seconds to add
<format><format> No StringString 单一格式的说明符自定义格式的模式Either a single format specifier or a custom format pattern. 时间戳的默认格式为“o”(yyyy-MM-ddT:mm:ss:fffffffK),这符合 ISO 8601 标准并保留了时区信息。The default format for the timestamp is "o" (yyyy-MM-ddTHH:mm:ss:fffffffK), which complies with ISO 8601 and preserves time zone information.
返回值Return value 类型Type 说明Description
<updated-timestamp><updated-timestamp> StringString 时间戳加上指定的秒数The timestamp plus the specified number of seconds

示例 1Example 1

此示例将 10 秒加到指定的时间戳:This example adds 10 seconds to the specified timestamp:

addSeconds('2018-03-15T00:00:00Z', 10)

并返回以下结果:"2018-03-15T00:00:10.0000000Z"And returns this result: "2018-03-15T00:00:10.0000000Z"

示例 2Example 2

此示例从指定的时间戳减去 5 秒:This example subtracts five seconds to the specified timestamp:

addSeconds('2018-03-15T00:00:30Z', -5)

并返回以下结果:"2018-03-15T00:00:25.0000000Z"And returns this result: "2018-03-15T00:00:25.0000000Z"

addToTimeaddToTime

将一定数目的时间单位加到时间戳。Add a number of time units to a timestamp. 另请参阅 getFutureTime()See also getFutureTime().

addToTime('<timestamp>', <interval>, '<timeUnit>', '<format>'?)
参数Parameter 必须Required 类型Type 说明Description
<timestamp><timestamp> Yes StringString 包含时间戳的字符串The string that contains the timestamp
<间隔><interval> Yes IntegerInteger 要添加的指定时间单位数The number of specified time units to add
<timeUnit><timeUnit> Yes StringString 间隔使用的时间单位:“秒”、“分钟”、“小时”、“日”、“周”、“月”、“年”The unit of time to use with interval: "Second", "Minute", "Hour", "Day", "Week", "Month", "Year"
<format><format> No StringString 单一格式的说明符自定义格式的模式Either a single format specifier or a custom format pattern. 时间戳的默认格式为“o”(yyyy-MM-ddT:mm:ss:fffffffK),这符合 ISO 8601 标准并保留了时区信息。The default format for the timestamp is "o" (yyyy-MM-ddTHH:mm:ss:fffffffK), which complies with ISO 8601 and preserves time zone information.
返回值Return value 类型Type 说明Description
<updated-timestamp><updated-timestamp> StringString 时间戳加上指定的时间单位数The timestamp plus the specified number of time units

示例 1Example 1

此示例将 1 天加到指定的时间戳:This example adds one day to the specified timestamp:

addToTime('2018-01-01T00:00:00Z', 1, 'Day')

并返回以下结果:"2018-01-02T00:00:00.0000000Z"And returns this result: "2018-01-02T00:00:00.0000000Z"

示例 2Example 2

此示例将 1 天加到指定的时间戳:This example adds one day to the specified timestamp:

addToTime('2018-01-01T00:00:00Z', 1, 'Day', 'D')

并使用可选的“D”格式返回结果:"Tuesday, January 2, 2018"And returns the result using the optional "D" format: "Tuesday, January 2, 2018"

andand

检查两个表达式是否均为 true。Check whether both expressions are true. 当两个表达式均为 true 时返回 true,当至少一个表达式为 false 时返回 false。Return true when both expressions are true, or return false when at least one expression is false.

and(<expression1>, <expression2>)
参数Parameter 必须Required 类型Type 说明Description
, <expression1>, <expression2> Yes 布尔Boolean 要检查的表达式The expressions to check
返回值Return value 类型Type 说明Description
true 或 falsetrue or false 布尔Boolean 当两个表达式均为 true 时返回 true。Return true when both expressions are true. 当至少一个表达式为 false 时返回 false。Return false when at least one expression is false.

示例 1Example 1

这些示例检查指定的布尔值是否均为 true:These examples check whether the specified Boolean values are both true:

and(true, true)
and(false, true)
and(false, false)

并返回以下结果:And returns these results:

  • 第一个示例:两个表达式均为 true,因此返回 trueFirst example: Both expressions are true, so returns true.
  • 第二个示例:一个表达式为 false,因此返回 falseSecond example: One expression is false, so returns false.
  • 第三个示例:两个表达式均为 false,因此返回 falseThird example: Both expressions are false, so returns false.

示例 2Example 2

这些示例检查指定的表达式是否均为 true:These examples check whether the specified expressions are both true:

and(equals(1, 1), equals(2, 2))
and(equals(1, 1), equals(1, 2))
and(equals(1, 2), equals(1, 3))

并返回以下结果:And returns these results:

  • 第一个示例:两个表达式均为 true,因此返回 trueFirst example: Both expressions are true, so returns true.
  • 第二个示例:一个表达式为 false,因此返回 falseSecond example: One expression is false, so returns false.
  • 第三个示例:两个表达式均为 false,因此返回 falseThird example: Both expressions are false, so returns false.

arrayarray

从单个指定的输入返回数组。Return an array from a single specified input. 对于多个输入,请参阅 createArray()For multiple inputs, see createArray().

array('<value>')
参数Parameter 必须Required 类型Type 说明Description
<value><value> Yes StringString 用于创建数组的字符串The string for creating an array
返回值Return value 类型Type 说明Description
[<value>][<value>] ArrayArray 一个包含单一指定输入的数组An array that contains the single specified input

示例Example

此示例基于“hello”字符串创建数组:This example creates an array from the "hello" string:

array('hello')

并返回以下结果:["hello"]And returns this result: ["hello"]

base64base64

返回字符串的 base64 编码版本。Return the base64-encoded version for a string.

base64('<value>')
参数Parameter 必须Required 类型Type 说明Description
<value><value> Yes StringString 输入字符串The input string
返回值Return value 类型Type 说明Description
<base64-string><base64-string> StringString 返回输入字符串的 base64 编码版本The base64-encoded version for the input string

示例Example

此示例将“hello”字符串转换为 base64 编码的字符串:This example converts the "hello" string to a base64-encoded string:

base64('hello')

并返回以下结果:"aGVsbG8="And returns this result: "aGVsbG8="

base64ToBinarybase64ToBinary

返回 base64 编码字符串的二进制版本。Return the binary version for a base64-encoded string.

base64ToBinary('<value>')
参数Parameter 必须Required 类型Type 说明Description
<value><value> Yes StringString 要转换的 base64 编码字符串The base64-encoded string to convert
返回值Return value 类型Type 说明Description
<binary-for-base64-string><binary-for-base64-string> StringString base64 编码字符串的二进制版本The binary version for the base64-encoded string

示例Example

此示例将 base64 编码的“aGVsbG8=”字符串转换为二进制字符串:This example converts the "aGVsbG8=" base64-encoded string to a binary string:

base64ToBinary('aGVsbG8=')

并返回以下结果:And returns this result:

"0110000101000111010101100111001101100010010001110011100000111101"

base64ToStringbase64ToString

返回 base64 编码字符串的字符串版本,有效地对 base64 字符串进行解码。Return the string version for a base64-encoded string, effectively decoding the base64 string. 请使用此函数而非 decodeBase64()Use this function rather than decodeBase64(). 虽然这两个函数的工作方式相同,但首选 base64ToString()Although both functions work the same way, base64ToString() is preferred.

base64ToString('<value>')
参数Parameter 必须Required 类型Type 说明Description
<value><value> Yes StringString 要解码的 base64 编码字符串The base64-encoded string to decode
返回值Return value 类型Type 说明Description
<decoded-base64-string><decoded-base64-string> StringString base64 编码字符串的字符串版本The string version for a base64-encoded string

示例Example

此示例将 base64 编码的“aGVsbG8=”字符串转换为单纯的字符串:This example converts the "aGVsbG8=" base64-encoded string to just a string:

base64ToString('aGVsbG8=')

并返回以下结果:"hello"And returns this result: "hello"

binarybinary

返回字符串的二进制版本。Return the binary version for a string.

binary('<value>')
参数Parameter 必须Required 类型Type 说明Description
<value><value> Yes StringString 要转换的字符串The string to convert
返回值Return value 类型Type 说明Description
<binary-for-input-value><binary-for-input-value> StringString 指定字符串的二进制版本The binary version for the specified string

示例Example

此示例将“hello”字符串转换为二进制字符串:This example converts the "hello" string to a binary string:

binary('hello')

并返回以下结果:And returns this result:

"0110100001100101011011000110110001101111"

boolbool

返回值的布尔版本。Return the Boolean version for a value.

bool(<value>)
参数Parameter 必须Required 类型Type 说明Description
<value><value> Yes 任意Any 要转换的值The value to convert
返回值Return value 类型Type 说明Description
true 或 falsetrue or false 布尔Boolean 指定的值的布尔版本The Boolean version for the specified value

示例Example

这些示例将指定的值转换为布尔值:These examples convert the specified values to Boolean values:

bool(1)
bool(0)

并返回以下结果:And returns these results:

  • 第一个示例:trueFirst example: true
  • 第二个示例:falseSecond example: false

coalescecoalesce

返回一个或多个参数中的第一个非 null 值。Return the first non-null value from one or more parameters. 空字符串、空数组和空对象不为 null。Empty strings, empty arrays, and empty objects are not null.

coalesce(<object_1>, <object_2>, ...)
参数Parameter 必须Required 类型Type 说明Description
<object_1>, <object_2>, ...<object_1>, <object_2>, ... Yes 任意,可以混用各种类型Any, can mix types 要检查是否为 null 的一个或多个项One or more items to check for null
返回值Return value 类型Type 说明Description
<first-non-null-item><first-non-null-item> 任意Any 第一个不为 null 的项或值。The first item or value that is not null. 如果所有参数均为 null,则此函数返回 null。If all parameters are null, this function returns null.

示例Example

这些示例返回指定值中的第一个非 null 值,当所有值均为 null 时返回 null:These examples return the first non-null value from the specified values, or null when all the values are null:

coalesce(null, true, false)
coalesce(null, 'hello', 'world')
coalesce(null, null, null)

并返回以下结果:And returns these results:

  • 第一个示例:trueFirst example: true
  • 第二个示例:"hello"Second example: "hello"
  • 第三个示例:nullThird example: null

concatconcat

组合两个或更多字符串,并返回组合后的字符串。Combine two or more strings, and return the combined string.

concat('<text1>', '<text2>', ...)
参数Parameter 必须Required 类型Type 说明Description
<text1>, <text2>, ...<text1>, <text2>, ... Yes StringString 至少两个要组合的字符串At least two strings to combine
返回值Return value 类型Type 说明Description
<text1text2... ><text1text2...> StringString 基于组合后的输入字符串创建的字符串The string created from the combined input strings

示例Example

此示例将字符串“Hello”和“World”组合到一起:This example combines the strings "Hello" and "World":

concat('Hello', 'World')

并返回以下结果:"HelloWorld"And returns this result: "HelloWorld"

containscontains

检查集合是否包含某个特定项。Check whether a collection has a specific item. 当找到该项目时返回 true,找不到该项目时返回 false。Return true when the item is found, or return false when not found. 此函数区分大小写。This function is case-sensitive.

contains('<collection>', '<value>')
contains([<collection>], '<value>')

具体而言,此函数对以下集合类型起作用:Specifically, this function works on these collection types:

  • 字符串,在其中查找子字符串A string to find a substring
  • 数组,在其中查找值An array to find a value
  • 字典,在其中查找键A dictionary to find a key
参数Parameter 必须Required 类型Type 说明Description
<collection><collection> Yes 字符串、数组或字典String, Array, or Dictionary 要检查的集合The collection to check
<value><value> Yes 分别为字符串、数组或字典String, Array, or Dictionary, respectively 要查找的项The item to find
返回值Return value 类型Type 说明Description
true 或 falsetrue or false 布尔Boolean 当找到该项时返回 true。Return true when the item is found. 找不到时返回 false。Return false when not found.

示例 1Example 1

此示例检查字符串“hello world”中是否有子字符串“world”并返回 true:This example checks the string "hello world" for the substring "world" and returns true:

contains('hello world', 'world')

示例 2Example 2

此示例检查字符串“hello world”中是否有子字符串“universe”并返回 false:This example checks the string "hello world" for the substring "universe" and returns false:

contains('hello world', 'universe')

convertFromUtcconvertFromUtc

将时间戳从协调世界时 (UTC) 转换为目标时区。Convert a timestamp from Universal Time Coordinated (UTC) to the target time zone.

convertFromUtc('<timestamp>', '<destinationTimeZone>', '<format>'?)
参数Parameter 必须Required 类型Type 说明Description
<timestamp><timestamp> Yes StringString 包含时间戳的字符串The string that contains the timestamp
<destinationTimeZone><destinationTimeZone> Yes StringString 目标时区的名称。The name for the target time zone. 有关时区名称,请参阅 Microsoft 时区索引值,但你可能需要删除时区名称中的任何标点。For time zone names, see Microsoft Time Zone Index Values, but you might have to remove any punctuation from the time zone name.
<format><format> No StringString 单一格式的说明符自定义格式的模式Either a single format specifier or a custom format pattern. 时间戳的默认格式为“o”(yyyy-MM-ddT:mm:ss:fffffffK),这符合 ISO 8601 标准并保留了时区信息。The default format for the timestamp is "o" (yyyy-MM-ddTHH:mm:ss:fffffffK), which complies with ISO 8601 and preserves time zone information.
返回值Return value 类型Type 说明Description
<converted-timestamp><converted-timestamp> StringString 已转换为目标时区的时间戳The timestamp converted to the target time zone

示例 1Example 1

此示例将时间戳转换为指定的时区:This example converts a timestamp to the specified time zone:

convertFromUtc('2018-01-01T08:00:00.0000000Z', 'Pacific Standard Time')

并返回以下结果:"2018-01-01T00:00:00Z"And returns this result: "2018-01-01T00:00:00Z"

示例 2Example 2

此示例将时间戳转换为指定的时区和格式:This example converts a timestamp to the specified time zone and format:

convertFromUtc('2018-01-01T08:00:00.0000000Z', 'Pacific Standard Time', 'D')

并返回以下结果:"Monday, January 1, 2018"And returns this result: "Monday, January 1, 2018"

convertTimeZoneconvertTimeZone

将时间戳从源时区转换为目标时区。Convert a timestamp from the source time zone to the target time zone.

convertTimeZone('<timestamp>', '<sourceTimeZone>', '<destinationTimeZone>', '<format>'?)
参数Parameter 必须Required 类型Type 说明Description
<timestamp><timestamp> Yes StringString 包含时间戳的字符串The string that contains the timestamp
<sourceTimeZone><sourceTimeZone> Yes StringString 源时区的名称。The name for the source time zone. 有关时区名称,请参阅 Microsoft 时区索引值,但你可能需要删除时区名称中的任何标点。For time zone names, see Microsoft Time Zone Index Values, but you might have to remove any punctuation from the time zone name.
<destinationTimeZone><destinationTimeZone> Yes StringString 目标时区的名称。The name for the target time zone. 有关时区名称,请参阅 Microsoft 时区索引值,但你可能需要删除时区名称中的任何标点。For time zone names, see Microsoft Time Zone Index Values, but you might have to remove any punctuation from the time zone name.
<format><format> No StringString 单一格式的说明符自定义格式的模式Either a single format specifier or a custom format pattern. 时间戳的默认格式为“o”(yyyy-MM-ddT:mm:ss:fffffffK),这符合 ISO 8601 标准并保留了时区信息。The default format for the timestamp is "o" (yyyy-MM-ddTHH:mm:ss:fffffffK), which complies with ISO 8601 and preserves time zone information.
返回值Return value 类型Type 说明Description
<converted-timestamp><converted-timestamp> StringString 已转换为目标时区的时间戳The timestamp converted to the target time zone

示例 1Example 1

此示例将源时区转换为目标时区:This example converts the source time zone to the target time zone:

convertTimeZone('2018-01-01T08:00:00.0000000Z', 'UTC', 'Pacific Standard Time')

并返回以下结果:"2018-01-01T00:00:00.0000000"And returns this result: "2018-01-01T00:00:00.0000000"

示例 2Example 2

此示例将时区转换为指定的时区和格式:This example converts a time zone to the specified time zone and format:

convertTimeZone('2018-01-01T80:00:00.0000000Z', 'UTC', 'Pacific Standard Time', 'D')

并返回以下结果:"Monday, January 1, 2018"And returns this result: "Monday, January 1, 2018"

convertToUtcconvertToUtc

将时间戳从源时区转换为协调世界时 (UTC)。Convert a timestamp from the source time zone to Universal Time Coordinated (UTC).

convertToUtc('<timestamp>', '<sourceTimeZone>', '<format>'?)
参数Parameter 必须Required 类型Type 说明Description
<timestamp><timestamp> Yes StringString 包含时间戳的字符串The string that contains the timestamp
<sourceTimeZone><sourceTimeZone> Yes StringString 源时区的名称。The name for the source time zone. 有关时区名称,请参阅 Microsoft 时区索引值,但你可能需要删除时区名称中的任何标点。For time zone names, see Microsoft Time Zone Index Values, but you might have to remove any punctuation from the time zone name.
<format><format> No StringString 单一格式的说明符自定义格式的模式Either a single format specifier or a custom format pattern. 时间戳的默认格式为“o”(yyyy-MM-ddT:mm:ss:fffffffK),这符合 ISO 8601 标准并保留了时区信息。The default format for the timestamp is "o" (yyyy-MM-ddTHH:mm:ss:fffffffK), which complies with ISO 8601 and preserves time zone information.
返回值Return value 类型Type 说明Description
<converted-timestamp><converted-timestamp> StringString 已转换为 UTC 的时间戳The timestamp converted to UTC

示例 1Example 1

此示例将时间戳转换为 UTC:This example converts a timestamp to UTC:

convertToUtc('01/01/2018 00:00:00', 'Pacific Standard Time')

并返回以下结果:"2018-01-01T08:00:00.0000000Z"And returns this result: "2018-01-01T08:00:00.0000000Z"

示例 2Example 2

此示例将时间戳转换为 UTC:This example converts a timestamp to UTC:

convertToUtc('01/01/2018 00:00:00', 'Pacific Standard Time', 'D')

并返回以下结果:"Monday, January 1, 2018"And returns this result: "Monday, January 1, 2018"

createArraycreateArray

从多个输入返回数组。Return an array from multiple inputs. 对于单输入数组,请参阅 array()For single input arrays, see array().

createArray('<object1>', '<object2>', ...)
参数Parameter 必须Required 类型Type 说明Description
<object1>, <object2>, ...<object1>, <object2>, ... Yes 任意,但不能混用Any, but not mixed 至少两个用于创建数组的项At least two items to create the array
返回值Return value 类型Type 说明Description
[<object1>, <object2>, ...][<object1>, <object2>, ...] ArrayArray 基于所有输入项创建的数组The array created from all the input items

示例Example

此示例基于以下输入创建数组:This example creates an array from these inputs:

createArray('h', 'e', 'l', 'l', 'o')

并返回以下结果:["h", "e", "l", "l", "o"]And returns this result: ["h", "e", "l", "l", "o"]

dataUridataUri

返回字符串的数据统一资源标识符 (URI)。Return a data uniform resource identifier (URI) for a string.

dataUri('<value>')
参数Parameter 必须Required 类型Type 说明Description
<value><value> Yes StringString 要转换的字符串The string to convert
返回值Return value 类型Type 说明Description
<data-uri><data-uri> StringString 输入字符串的数据 URIThe data URI for the input string

示例Example

此示例创建“hello”字符串的数据 URI:This example creates a data URI for the "hello" string:

dataUri('hello')

并返回以下结果:"data:text/plain;charset=utf-8;base64,aGVsbG8="And returns this result: "data:text/plain;charset=utf-8;base64,aGVsbG8="

dataUriToBinarydataUriToBinary

返回数据统一资源标识符 (URI) 的二进制版本。Return the binary version for a data uniform resource identifier (URI). 请使用此函数而非 decodeDataUri()Use this function rather than decodeDataUri(). 虽然这两个函数的工作方式相同,但首选 dataUriBinary()Although both functions work the same way, dataUriBinary() is preferred.

dataUriToBinary('<value>')
参数Parameter 必须Required 类型Type 说明Description
<value><value> Yes StringString 要转换的数据 URIThe data URI to convert
返回值Return value 类型Type 说明Description
<binary-for-data-uri><binary-for-data-uri> StringString 数据 URI 的二进制版本The binary version for the data URI

示例Example

此示例创建以下数据 URI 的二进制版本:This example creates a binary version for this data URI:

dataUriToBinary('data:text/plain;charset=utf-8;base64,aGVsbG8=')

并返回以下结果:And returns this result:

"01100100011000010111010001100001001110100111010001100101011110000111010000101111011100000 1101100011000010110100101101110001110110110001101101000011000010111001001110011011001010111 0100001111010111010101110100011001100010110100111000001110110110001001100001011100110110010 10011011000110100001011000110000101000111010101100111001101100010010001110011100000111101"

dataUriToStringdataUriToString

返回数据统一资源标识符 (URI) 的字符串版本。Return the string version for a data uniform resource identifier (URI).

dataUriToString('<value>')
参数Parameter 必须Required 类型Type 说明Description
<value><value> Yes StringString 要转换的数据 URIThe data URI to convert
返回值Return value 类型Type 说明Description
<string-for-data-uri><string-for-data-uri> StringString 数据 URI 的字符串版本The string version for the data URI

示例Example

此示例创建以下数据 URI 的字符串:This example creates a string for this data URI:

dataUriToString('data:text/plain;charset=utf-8;base64,aGVsbG8=')

并返回以下结果:"hello"And returns this result: "hello"

dayOfMonthdayOfMonth

基于时间戳返回月中的某天。Return the day of the month from a timestamp.

dayOfMonth('<timestamp>')
参数Parameter 必须Required 类型Type 说明Description
<timestamp><timestamp> Yes StringString 包含时间戳的字符串The string that contains the timestamp
返回值Return value 类型Type 说明Description
<day-of-month><day-of-month> IntegerInteger 基于指定的时间戳返回月中的某天The day of the month from the specified timestamp

示例Example

此示例基于以下时间戳返回月中的某天:This example returns the number for the day of the month from this timestamp:

dayOfMonth('2018-03-15T13:27:36Z')

并返回以下结果:15And returns this result: 15

dayOfWeekdayOfWeek

基于时间戳返回周几。Return the day of the week from a timestamp.

dayOfWeek('<timestamp>')
参数Parameter 必须Required 类型Type 说明Description
<timestamp><timestamp> Yes StringString 包含时间戳的字符串The string that contains the timestamp
返回值Return value 类型Type 说明Description
<day-of-week><day-of-week> IntegerInteger 指定的时间戳中的周几,其中周日为 0,周一为 1,依此类推The day of the week from the specified timestamp where Sunday is 0, Monday is 1, and so on

示例Example

此示例基于以下时间戳返回周几:This example returns the number for the day of the week from this timestamp:

dayOfWeek('2018-03-15T13:27:36Z')

并返回以下结果:3And returns this result: 3

dayOfYeardayOfYear

基于时间戳返回年中的某天。Return the day of the year from a timestamp.

dayOfYear('<timestamp>')
参数Parameter 必须Required 类型Type 说明Description
<timestamp><timestamp> Yes StringString 包含时间戳的字符串The string that contains the timestamp
返回值Return value 类型Type 说明Description
<day-of-year><day-of-year> IntegerInteger 基于指定的时间戳返回年中的某天The day of the year from the specified timestamp

示例Example

此示例基于以下时间戳返回年中的某天:This example returns the number of the day of the year from this timestamp:

dayOfYear('2018-03-15T13:27:36Z')

并返回以下结果:74And returns this result: 74

decodeBase64decodeBase64

返回 base64 编码字符串的字符串版本,有效地对 base64 字符串进行解码。Return the string version for a base64-encoded string, effectively decoding the base64 string. 请考虑使用 base64ToString() 而非 decodeBase64()Consider using base64ToString() rather than decodeBase64(). 虽然这两个函数的工作方式相同,但首选 base64ToString()Although both functions work the same way, base64ToString() is preferred.

decodeBase64('<value>')
参数Parameter 必须Required 类型Type 说明Description
<value><value> Yes StringString 要解码的 base64 编码字符串The base64-encoded string to decode
返回值Return value 类型Type 说明Description
<decoded-base64-string><decoded-base64-string> StringString base64 编码字符串的字符串版本The string version for a base64-encoded string

示例Example

此示例创建一个 base64 编码字符串的字符串:This example creates a string for a base64-encoded string:

decodeBase64('aGVsbG8=')

并返回以下结果:"hello"And returns this result: "hello"

decodeDataUridecodeDataUri

返回数据统一资源标识符 (URI) 的二进制版本。Return the binary version for a data uniform resource identifier (URI). 请考虑使用 dataUriToBinary() 而非 decodeDataUri()Consider using dataUriToBinary(), rather than decodeDataUri(). 虽然这两个函数的工作方式相同,但首选 dataUriToBinary()Although both functions work the same way, dataUriToBinary() is preferred.

decodeDataUri('<value>')
参数Parameter 必须Required 类型Type 说明Description
<value><value> Yes StringString 要解码的数据 URI 字符串The data URI string to decode
返回值Return value 类型Type 说明Description
<binary-for-data-uri><binary-for-data-uri> StringString 数据 URI 字符串的二进制版本The binary version for a data URI string

示例Example

此示例返回以下数据 URI 的二进制版本:This example returns the binary version for this data URI:

decodeDataUri('data:text/plain;charset=utf-8;base64,aGVsbG8=')

并返回以下结果:And returns this result:

"01100100011000010111010001100001001110100111010001100101011110000111010000101111011100000 1101100011000010110100101101110001110110110001101101000011000010111001001110011011001010111 0100001111010111010101110100011001100010110100111000001110110110001001100001011100110110010 10011011000110100001011000110000101000111010101100111001101100010010001110011100000111101"

decodeUriComponentdecodeUriComponent

返回一个字符串,并将其中的转义字符替换为解码后的版本。Return a string that replaces escape characters with decoded versions.

decodeUriComponent('<value>')
参数Parameter 必须Required 类型Type 说明Description
<value><value> Yes StringString 包含要解码的转义字符的字符串The string with the escape characters to decode
返回值Return value 类型Type 说明Description
<decoded-uri><decoded-uri> StringString 包含解码后的转义字符的更新后字符串The updated string with the decoded escape characters

示例Example

此示例将以下字符串中的转义字符替换为解码后的版本:This example replaces the escape characters in this string with decoded versions:

decodeUriComponent('http%3A%2F%2Fcontoso.com')

并返回以下结果:"https://contoso.com"And returns this result: "https://contoso.com"

divdiv

返回将两个数字相除后的整数结果。Return the integer result from dividing two numbers. 若要获取余数结果,请参阅 mod()To get the remainder result, see mod().

div(<dividend>, <divisor>)
参数Parameter 必须Required 类型Type 说明Description
<dividend><dividend> Yes 整数或浮点数Integer or Float 要用作 divisor 的被除数的数字The number to divide by the divisor
<divisor><divisor> Yes 整数或浮点数Integer or Float 用作 dividend 的除数的数字,但不能为 0The number that divides the dividend, but cannot be 0
返回值Return value 类型Type 说明Description
<quotient-result><quotient-result> IntegerInteger 将第一个数字除以第二个数字后得到的整数结果The integer result from dividing the first number by the second number

示例Example

两个示例都将第一个数字除以第二个数字:Both examples divide the first number by the second number:

div(10, 5)
div(11, 5)

并返回以下结果:2And return this result: 2

encodeUriComponentencodeUriComponent

通过将 URL 不安全字符替换为转义字符来返回字符串的统一资源标识符 (URI) 编码版本。Return a uniform resource identifier (URI) encoded version for a string by replacing URL-unsafe characters with escape characters. 请考虑使用 uriComponent() 而非 encodeUriComponent()Consider using uriComponent(), rather than encodeUriComponent(). 虽然这两个函数的工作方式相同,但首选 uriComponent()Although both functions work the same way, uriComponent() is preferred.

encodeUriComponent('<value>')
参数Parameter 必须Required 类型Type 说明Description
<value><value> Yes StringString 要转换为 URI 编码格式的字符串The string to convert to URI-encoded format
返回值Return value 类型Type 说明Description
<encoded-uri><encoded-uri> StringString 带有转义字符的 URI 编码字符串The URI-encoded string with escape characters

示例Example

此示例创建以下字符串的 URI 编码版本:This example creates a URI-encoded version for this string:

encodeUriComponent('https://contoso.com')

并返回以下结果:"http%3A%2F%2Fcontoso.com"And returns this result: "http%3A%2F%2Fcontoso.com"

emptyempty

检查集合是否为空。Check whether a collection is empty. 当集合为空时返回 true,不为空时返回 false。Return true when the collection is empty, or return false when not empty.

empty('<collection>')
empty([<collection>])
参数Parameter 必须Required 类型Type 说明Description
<collection><collection> Yes 字符串、数组或对象String, Array, or Object 要检查的集合The collection to check
返回值Return value 类型Type 说明Description
true 或 falsetrue or false 布尔Boolean 当集合为空时返回 true。Return true when the collection is empty. 不为空时返回 false。Return false when not empty.

示例Example

这些示例检查指定的集合是否为空:These examples check whether the specified collections are empty:

empty('')
empty('abc')

并返回以下结果:And returns these results:

  • 第一个示例:传递一个空字符串,所以此函数返回 trueFirst example: Passes an empty string, so the function returns true.
  • 第二个示例:传递字符串“abc”,所以此函数返回 falseSecond example: Passes the string "abc", so the function returns false.

endsWithendsWith

检查字符串是否以特定的子字符串结尾。Check whether a string ends with a specific substring. 当找到该子字符串时返回 true,找不到时返回 false。Return true when the substring is found, or return false when not found. 此函数不区分大小写。This function is not case-sensitive.

endsWith('<text>', '<searchText>')
参数Parameter 必须Required 类型Type 说明Description
<text><text> Yes StringString 要检查的字符串The string to check
<searchText><searchText> Yes StringString 要查找的结尾子字符串The ending substring to find
返回值Return value 类型Type 说明Description
true 或 falsetrue or false 布尔Boolean 当找到结尾子字符串时返回 true。Return true when the ending substring is found. 找不到时返回 false。Return false when not found.

示例 1Example 1

此示例检查“hello world”字符串是否以“world”字符串结尾:This example checks whether the "hello world" string ends with the "world" string:

endsWith('hello world', 'world')

并返回以下结果:trueAnd returns this result: true

示例 2Example 2

此示例检查“hello world”字符串是否以“universe”字符串结尾:This example checks whether the "hello world" string ends with the "universe" string:

endsWith('hello world', 'universe')

并返回以下结果:falseAnd returns this result: false

equalsequals

检查两个值、表达式或对象是否相等。Check whether both values, expressions, or objects are equivalent. 当两者相等时返回 true,两者不相等时返回 false。Return true when both are equivalent, or return false when they're not equivalent.

equals('<object1>', '<object2>')
参数Parameter 必须Required 类型Type 说明Description
<object1>, <object2><object1>, <object2> Yes 各种各样Various 要比较的值、表达式或对象The values, expressions, or objects to compare
返回值Return value 类型Type 说明Description
true 或 falsetrue or false 布尔Boolean 当两者相等时返回 true。Return true when both are equivalent. 不相等时返回 false。Return false when not equivalent.

示例Example

这些示例检查指定的输入是否相等。These examples check whether the specified inputs are equivalent.

equals(true, 1)
equals('abc', 'abcd')

并返回以下结果:And returns these results:

  • 第一个示例:两个值相等,所以此函数返回 trueFirst example: Both values are equivalent, so the function returns true.
  • 第二个示例:两个值不相等,所以此函数返回 falseSecond example: Both values aren't equivalent, so the function returns false.

firstfirst

返回字符串或数组中的第一项。Return the first item from a string or array.

first('<collection>')
first([<collection>])
参数Parameter 必须Required 类型Type 说明Description
<collection><collection> Yes 字符串或数组String or Array 要在其中查找第一项的集合The collection where to find the first item
返回值Return value 类型Type 说明Description
<first-collection-item><first-collection-item> 任意Any 集合中的第一项The first item in the collection

示例Example

这些示例查找以下集合中的第一项:These examples find the first item in these collections:

first('hello')
first(createArray(0, 1, 2))

并返回以下结果:And return these results:

  • 第一个示例:"h"First example: "h"
  • 第二个示例:0Second example: 0

floatfloat

将浮点数的字符串版本转换为实际的浮点数。Convert a string version for a floating-point number to an actual floating point number.

float('<value>')
参数Parameter 必须Required 类型Type 说明Description
<value><value> Yes StringString 包含要转换的有效浮点数的字符串The string that has a valid floating-point number to convert
返回值Return value 类型Type 说明Description
<float-value><float-value> FloatFloat 指定的字符串的浮点数The floating-point number for the specified string

示例Example

此示例创建以下浮点数的字符串版本:This example creates a string version for this floating-point number:

float('10.333')

并返回以下结果:10.333And returns this result: 10.333

formatDateTimeformatDateTime

以指定的格式返回时间戳。Return a timestamp in the specified format.

formatDateTime('<timestamp>', '<format>'?)
参数Parameter 必须Required 类型Type 说明Description
<timestamp><timestamp> Yes StringString 包含时间戳的字符串The string that contains the timestamp
<format><format> No StringString 单一格式的说明符自定义格式的模式Either a single format specifier or a custom format pattern. 时间戳的默认格式为“o”(yyyy-MM-ddT:mm:ss:fffffffK),这符合 ISO 8601 标准并保留了时区信息。The default format for the timestamp is "o" (yyyy-MM-ddTHH:mm:ss:fffffffK), which complies with ISO 8601 and preserves time zone information.
返回值Return value 类型Type 说明Description
<reformatted-timestamp><reformatted-timestamp> StringString 采用指定格式的更新后时间戳The updated timestamp in the specified format

示例Example

此示例将时间戳转换为指定的格式:This example converts a timestamp to the specified format:

formatDateTime('03/15/2018 12:00:00', 'yyyy-MM-ddTHH:mm:ss')

并返回以下结果:"2018-03-15T12:00:00"And returns this result: "2018-03-15T12:00:00"

getFutureTimegetFutureTime

返回当前时间戳加上指定的时间单位。Return the current timestamp plus the specified time units.

getFutureTime(<interval>, <timeUnit>, <format>?)
参数Parameter 必须Required 类型Type 说明Description
<间隔><interval> Yes IntegerInteger 要添加的指定时间单位数The number of specified time units to add
<timeUnit><timeUnit> Yes StringString 间隔使用的时间单位:“秒”、“分钟”、“小时”、“日”、“周”、“月”、“年”The unit of time to use with interval: "Second", "Minute", "Hour", "Day", "Week", "Month", "Year"
<format><format> No StringString 单一格式的说明符自定义格式的模式Either a single format specifier or a custom format pattern. 时间戳的默认格式为“o”(yyyy-MM-ddT:mm:ss:fffffffK),这符合 ISO 8601 标准并保留了时区信息。The default format for the timestamp is "o" (yyyy-MM-ddTHH:mm:ss:fffffffK), which complies with ISO 8601 and preserves time zone information.
返回值Return value 类型Type 说明Description
<updated-timestamp><updated-timestamp> StringString 当前时间戳加上指定的时间单位数The current timestamp plus the specified number of time units

示例 1Example 1

假设当前时间戳是“2018-03-01T00:00:00.0000000Z”。Suppose the current timestamp is "2018-03-01T00:00:00.0000000Z". 此示例将 5 天加到该时间戳:This example adds five days to that timestamp:

getFutureTime(5, 'Day')

并返回以下结果:"2018-03-06T00:00:00.0000000Z"And returns this result: "2018-03-06T00:00:00.0000000Z"

示例 2Example 2

假设当前时间戳是“2018-03-01T00:00:00.0000000Z”。Suppose the current timestamp is "2018-03-01T00:00:00.0000000Z". 此示例加上 5 天,并将结果转换为“D”格式:This example adds five days and converts the result to "D" format:

getFutureTime(5, 'Day', 'D')

并返回以下结果:"Tuesday, March 6, 2018"And returns this result: "Tuesday, March 6, 2018"

getPastTimegetPastTime

返回当前时间戳减去指定的时间单位。Return the current timestamp minus the specified time units.

getPastTime(<interval>, <timeUnit>, <format>?)
参数Parameter 必须Required 类型Type 说明Description
<间隔><interval> Yes IntegerInteger 要减去的指定时间单位数The number of specified time units to subtract
<timeUnit><timeUnit> Yes StringString 间隔使用的时间单位:“秒”、“分钟”、“小时”、“日”、“周”、“月”、“年”The unit of time to use with interval: "Second", "Minute", "Hour", "Day", "Week", "Month", "Year"
<format><format> No StringString 单一格式的说明符自定义格式的模式Either a single format specifier or a custom format pattern. 时间戳的默认格式为“o”(yyyy-MM-ddT:mm:ss:fffffffK),这符合 ISO 8601 标准并保留了时区信息。The default format for the timestamp is "o" (yyyy-MM-ddTHH:mm:ss:fffffffK), which complies with ISO 8601 and preserves time zone information.
返回值Return value 类型Type 说明Description
<updated-timestamp><updated-timestamp> StringString 当前时间戳减去指定的时间单位数The current timestamp minus the specified number of time units

示例 1Example 1

假设当前时间戳是“2018-02-01T00:00:00.0000000Z”。Suppose the current timestamp is "2018-02-01T00:00:00.0000000Z". 此示例从该时间戳减去 5 天:This example subtracts five days from that timestamp:

getPastTime(5, 'Day')

并返回以下结果:"2018-01-27T00:00:00.0000000Z"And returns this result: "2018-01-27T00:00:00.0000000Z"

示例 2Example 2

假设当前时间戳是“2018-02-01T00:00:00.0000000Z”。Suppose the current timestamp is "2018-02-01T00:00:00.0000000Z". 此示例减去 5 天,并将结果转换为“D”格式:This example subtracts five days and converts the result to "D" format:

getPastTime(5, 'Day', 'D')

并返回以下结果:"Saturday, January 27, 2018"And returns this result: "Saturday, January 27, 2018"

greatergreater

检查第一个值是否大于第二个值。Check whether the first value is greater than the second value. 如果第一个值大,则返回 true;如果第一个值小,则返回 false。Return true when the first value is more, or return false when less.

greater(<value>, <compareTo>)
greater('<value>', '<compareTo>')
参数Parameter 必须Required 类型Type 说明Description
<value><value> Yes 整数、浮点数或字符串Integer, Float, or String 要检查是否大于第二个值的第一个值。The first value to check whether greater than the second value
<compareTo><compareTo> Yes 分别为整数、浮点数或字符串Integer, Float, or String, respectively 比较值The comparison value
返回值Return value 类型Type 说明Description
true 或 falsetrue or false 布尔Boolean 当第一个值大于第二个值时返回 true。Return true when the first value is greater than the second value. 当第一个值等于或小于第二个值时返回 false。Return false when the first value is equal to or less than the second value.

示例Example

这些示例检查第一个值是否大于第二个值:These examples check whether the first value is greater than the second value:

greater(10, 5)
greater('apple', 'banana')

并返回以下结果:And return these results:

  • 第一个示例:trueFirst example: true
  • 第二个示例:falseSecond example: false

greaterOrEqualsgreaterOrEquals

检查第一个值是否大于或等于第二个值。Check whether the first value is greater than or equal to the second value. 当第一个值大于或等于第二个值时返回 true,当第一个值小于第二个值时返回 false。Return true when the first value is greater or equal, or return false when the first value is less.

greaterOrEquals(<value>, <compareTo>)
greaterOrEquals('<value>', '<compareTo>')
参数Parameter 必须Required 类型Type 说明Description
<value><value> Yes 整数、浮点数或字符串Integer, Float, or String 要检查是否大于或等于第二个值的第一个值The first value to check whether greater than or equal to the second value
<compareTo><compareTo> Yes 分别为整数、浮点数或字符串Integer, Float, or String, respectively 比较值The comparison value
返回值Return value 类型Type 说明Description
true 或 falsetrue or false 布尔Boolean 当第一个值大于或等于第二个值时返回 true。Return true when the first value is greater than or equal to the second value. 当第一个值小于第二个值时返回 false。Return false when the first value is less than the second value.

示例Example

这些示例检查第一个值是否大于或等于第二个值:These examples check whether the first value is greater or equal than the second value:

greaterOrEquals(5, 5)
greaterOrEquals('apple', 'banana')

并返回以下结果:And return these results:

  • 第一个示例:trueFirst example: true
  • 第二个示例:falseSecond example: false

GUIDguid

生成一个字符串形式的全局唯一标识符 (GUID),例如“c2ecc88d-88c8-4096-912c-d6f2e2b138ce”:Generate a globally unique identifier (GUID) as a string, for example, "c2ecc88d-88c8-4096-912c-d6f2e2b138ce":

guid()

此外,还可以为 GUID 指定与默认格式“D”(由连字符分隔的 32 位数字)不同的格式。Also, you can specify a different format for the GUID other than the default format, "D", which is 32 digits separated by hyphens.

guid('<format>')
参数Parameter 必须Required 类型Type 说明Description
<format><format> No StringString 表示返回的 GUID 的单一格式说明符A single format specifier for the returned GUID. 默认情况下,格式为“D”,但可以使用“N”、“D”、“B”、“P”或“X”。By default, the format is "D", but you can use "N", "D", "B", "P", or "X".
返回值Return value 类型Type 说明Description
<GUID-value><GUID-value> StringString 随机生成的 GUIDA randomly generated GUID

示例Example

此示例生成相同的 GUID,但它是 32 位的,以连字符分隔并括在括号中:This example generates the same GUID, but as 32 digits, separated by hyphens, and enclosed in parentheses:

guid('P')

并返回以下结果:"(c2ecc88d-88c8-4096-912c-d6f2e2b138ce)"And returns this result: "(c2ecc88d-88c8-4096-912c-d6f2e2b138ce)"

ifif

检查表达式为 true 还是 false。Check whether an expression is true or false. 根据结果返回指定的值。Based on the result, return a specified value.

if(<expression>, <valueIfTrue>, <valueIfFalse>)
参数Parameter 必须Required 类型Type 说明Description
<expression><expression> Yes 布尔Boolean 要检查的表达式The expression to check
<valueIfTrue><valueIfTrue> Yes 任意Any 当表达式为 true 时要返回的值The value to return when the expression is true
<valueIfFalse><valueIfFalse> Yes 任意Any 当表达式为 false 时要返回的值The value to return when the expression is false
返回值Return value 类型Type 说明Description
<specified-return-value><specified-return-value> 任意Any 根据表达式为 true 或 false 返回的指定值The specified value that returns based on whether the expression is true or false

示例Example

此示例返回 "yes",因为指定的表达式返回 true。This example returns "yes" because the specified expression returns true. 否则,此示例返回 "no"Otherwise, the example returns "no":

if(equals(1, 1), 'yes', 'no')

indexOfindexOf

返回子字符串的起始位置或索引值。Return the starting position or index value for a substring. 此函数不区分大小写,并且索引从数字 0 开始。This function is not case-sensitive, and indexes start with the number 0.

indexOf('<text>', '<searchText>')
参数Parameter 必须Required 类型Type 说明Description
<text><text> Yes StringString 包含要查找的子字符串的字符串The string that has the substring to find
<searchText><searchText> Yes StringString 要查找的子字符串The substring to find
返回值Return value 类型Type 说明Description
<index-value><index-value> IntegerInteger 指定的子字符串的起始位置或索引值。The starting position or index value for the specified substring.

如果未找到该字符串,则返回数字 -1。If the string is not found, return the number -1.

示例Example

此示例查找“hello world”字符串中的“world”子字符串的起始索引值:This example finds the starting index value for the "world" substring in the "hello world" string:

indexOf('hello world', 'world')

并返回以下结果:6And returns this result: 6

intint

返回字符串的整数版本。Return the integer version for a string.

int('<value>')
参数Parameter 必须Required 类型Type 说明Description
<value><value> Yes StringString 要转换的字符串The string to convert
返回值Return value 类型Type 说明Description
<integer-result><integer-result> IntegerInteger 指定的字符串的整数版本The integer version for the specified string

示例Example

此示例创建字符串“10”的整数版本:This example creates an integer version for the string "10":

int('10')

并返回以下结果:10And returns this result: 10

jsonjson

返回字符串或 XML 的 JavaScript 对象表示法 (JSON) 类型的值或对象。Return the JavaScript Object Notation (JSON) type value or object for a string or XML.

json('<value>')
参数Parameter 必须Required 类型Type 说明Description
<value><value> Yes 字符串或 XMLString or XML 要转换的字符串或 XMLThe string or XML to convert
返回值Return value 类型Type 说明Description
<JSON-result><JSON-result> JSON 本机类型或对象JSON native type or object 指定的字符串或 XML 的 JSON 本机类型的值或对象。The JSON native type value or object for the specified string or XML. 如果字符串为 null,则此函数返回一个空对象。If the string is null, the function returns an empty object.

示例 1Example 1

此示例将以下字符串转换为 JSON 值:This example converts this string to the JSON value:

json('[1, 2, 3]')

并返回以下结果:[1, 2, 3]And returns this result: [1, 2, 3]

示例 2Example 2

此示例将以下字符串转换为 JSON:This example converts this string to JSON:

json('{"fullName": "Sophia Owen"}')

并返回以下结果:And returns this result:

{
  "fullName": "Sophia Owen"
}

示例 3Example 3

此示例将以下 XML 转换为 JSON:This example converts this XML to JSON:

json(xml('<?xml version="1.0"?> <root> <person id='1'> <name>Sophia Owen</name> <occupation>Engineer</occupation> </person> </root>'))

并返回以下结果:And returns this result:

{
   "?xml": { "@version": "1.0" },
   "root": {
      "person": [ {
         "@id": "1",
         "name": "Sophia Owen",
         "occupation": "Engineer"
      } ]
   }
}

intersectionintersection

返回其中仅包含指定集合的共有项的一个集合。Return a collection that has only the common items across the specified collections. 某个项必须出现在传递给此函数的所有集合中才会出现在结果中。To appear in the result, an item must appear in all the collections passed to this function. 如果一个或多个项具有相同的名称,则具有该名称的最后一项将出现在结果中。If one or more items have the same name, the last item with that name appears in the result.

intersection([<collection1>], [<collection2>], ...)
intersection('<collection1>', '<collection2>', ...)
参数Parameter 必须Required 类型Type 说明Description
<collection1>, <collection2>, ...<collection1>, <collection2>, ... Yes 数组或对象,但不能为两者Array or Object, but not both 仅需从中获取共有项的各个集合The collections from where you want only the common items
返回值Return value 类型Type 说明Description
<common-items><common-items> 分别为数组或对象Array or Object, respectively 其中仅包含指定集合的共有项的一个集合A collection that has only the common items across the specified collections

示例Example

此示例查找以下数组中的共有项:This example finds the common items across these arrays:

intersection(createArray(1, 2, 3), createArray(101, 2, 1, 10), createArray(6, 8, 1, 2))

并返回“仅”包含这些项的数组:[1, 2]And returns an array with only these items: [1, 2]

joinjoin

返回一个字符串,它包含某个数组中的所有项并且以分隔符分隔每个字符。Return a string that has all the items from an array and has each character separated by a delimiter.

join([<collection>], '<delimiter>')
参数Parameter 必须Required 类型Type 说明Description
<collection><collection> Yes ArrayArray 包含要联接的项的数组The array that has the items to join
<delimiter><delimiter> Yes StringString 出现在结果字符串中的每个字符之间的分隔符The separator that appears between each character in the resulting string
返回值Return value 类型Type 说明Description
<char1><delimiter><char2><delimiter>...<char1><delimiter><char2><delimiter>... StringString 基于指定数组中的所有项创建的结果字符串The resulting string created from all the items in the specified array

示例Example

此示例基于以下数组中的所有项创建字符串,并且以指定的字符作为分隔符:This example creates a string from all the items in this array with the specified character as the delimiter:

join(createArray('a', 'b', 'c'), '.')

并返回以下结果:"a.b.c"And returns this result: "a.b.c"

lastlast

返回集合中的最后一个项。Return the last item from a collection.

last('<collection>')
last([<collection>])
参数Parameter 必须Required 类型Type 说明Description
<collection><collection> Yes 字符串或数组String or Array 要在其中查找最后一项的集合The collection where to find the last item
返回值Return value 类型Type 说明Description
<last-collection-item><last-collection-item> 分别为字符串或数组String or Array, respectively 集合中的最后一项The last item in the collection

示例Example

这些示例查找以下集合中的最后一项:These examples find the last item in these collections:

last('abcd')
last(createArray(0, 1, 2, 3))

并返回以下结果:And returns these results:

  • 第一个示例:"d"First example: "d"
  • 第二个示例:3Second example: 3

lastIndexOflastIndexOf

返回最后一次出现的子字符串的起始位置或索引值。Return the starting position or index value for the last occurrence of a substring. 此函数不区分大小写,并且索引从数字 0 开始。This function is not case-sensitive, and indexes start with the number 0.

lastIndexOf('<text>', '<searchText>')
参数Parameter 必须Required 类型Type 说明Description
<text><text> Yes StringString 包含要查找的子字符串的字符串The string that has the substring to find
<searchText><searchText> Yes StringString 要查找的子字符串The substring to find
返回值Return value 类型Type 说明Description
<ending-index-value><ending-index-value> IntegerInteger 最后一次出现的指定子字符串的起始位置或索引值。The starting position or index value for the last occurrence of the specified substring.

如果未找到该字符串,则返回数字 -1。If the string is not found, return the number -1.

示例Example

此示例查找“hello world”字符串中最后一次出现的“world”子字符串的起始索引值:This example finds the starting index value for the last occurrence of the "world" substring in the "hello world" string:

lastIndexOf('hello world', 'world')

并返回以下结果:6And returns this result: 6

lengthlength

返回集合中的项数。Return the number of items in a collection.

length('<collection>')
length([<collection>])
参数Parameter 必须Required 类型Type 说明Description
<collection><collection> Yes 字符串或数组String or Array 包含要计数的项的集合The collection with the items to count
返回值Return value 类型Type 说明Description
<length-or-count><length-or-count> IntegerInteger 集合中的项数The number of items in the collection

示例Example

这些示例对以下集合中的项数进行计数:These examples count the number of items in these collections:

length('abcd')
length(createArray(0, 1, 2, 3))

并返回以下结果:4And return this result: 4

lessless

检查第一个值是否小于第二个值。Check whether the first value is less than the second value. 如果第一个值小,则返回 true;如果第一个值大,则返回 false。Return true when the first value is less, or return false when the first value is more.

less(<value>, <compareTo>)
less('<value>', '<compareTo>')
参数Parameter 必须Required 类型Type 说明Description
<value><value> Yes 整数、浮点数或字符串Integer, Float, or String 要检查是否小于第二个值的第一个值The first value to check whether less than the second value
<compareTo><compareTo> Yes 分别为整数、浮点数或字符串Integer, Float, or String, respectively 比较项The comparison item
返回值Return value 类型Type 说明Description
true 或 falsetrue or false 布尔Boolean 当第一个值小于第二个值时返回 true。Return true when the first value is less than the second value. 当第一个值等于或大于第二个值时返回 false。Return false when the first value is equal to or greater than the second value.

示例Example

这些示例检查第一个值是否小于第二个值。These examples check whether the first value is less than the second value.

less(5, 10)
less('banana', 'apple')

并返回以下结果:And return these results:

  • 第一个示例:trueFirst example: true
  • 第二个示例:falseSecond example: false

lessOrEqualslessOrEquals

检查第一个值是否小于或等于第二个值。Check whether the first value is less than or equal to the second value. 当第一个值小于或等于第二个值时返回 true,当第一个值大时返回 false。Return true when the first value is less than or equal, or return false when the first value is more.

lessOrEquals(<value>, <compareTo>)
lessOrEquals('<value>', '<compareTo>')
参数Parameter 必须Required 类型Type 说明Description
<value><value> Yes 整数、浮点数或字符串Integer, Float, or String 要检查是否小于或等于第二个值的第一个值The first value to check whether less than or equal to the second value
<compareTo><compareTo> Yes 分别为整数、浮点数或字符串Integer, Float, or String, respectively 比较项The comparison item
返回值Return value 类型Type 说明Description
true 或 falsetrue or false 布尔Boolean 当第一个值小于或等于第二个值时返回 true。Return true when the first value is less than or equal to the second value. 当第一个值大于第二个值时返回 false。Return false when the first value is greater than the second value.

示例Example

这些示例检查第一个值是否小于或等于第二个值。These examples check whether the first value is less or equal than the second value.

lessOrEquals(10, 10)
lessOrEquals('apply', 'apple')

并返回以下结果:And return these results:

  • 第一个示例:trueFirst example: true
  • 第二个示例:falseSecond example: false

maxmax

返回列表中或包括两端数字在内的数组中的最大值。Return the highest value from a list or array with numbers that is inclusive at both ends.

max(<number1>, <number2>, ...)
max([<number1>, <number2>, ...])
参数Parameter 必须Required 类型Type 说明Description
<number1>, <number2>, ...<number1>, <number2>, ... Yes 整数、浮点数或两者Integer, Float, or both 需要从中获取最大值的数字集The set of numbers from which you want the highest value
[<number1>, <number2>, ...][<number1>, <number2>, ...] Yes 数组 - 整数、浮点数或两者Array - Integer, Float, or both 需要从中获取最大值的数字数组The array of numbers from which you want the highest value
返回值Return value 类型Type 说明Description
<max-value><max-value> 整数或浮点数Integer or Float 指定的数组或数字集中的最大值The highest value in the specified array or set of numbers

示例Example

这些示例获取数字集和数组中的最大值:These examples get the highest value from the set of numbers and the array:

max(1, 2, 3)
max(createArray(1, 2, 3))

并返回以下结果:3And return this result: 3

minmin

返回一组数字或数组中的最小值。Return the lowest value from a set of numbers or an array.

min(<number1>, <number2>, ...)
min([<number1>, <number2>, ...])
参数Parameter 必须Required 类型Type 说明Description
<number1>, <number2>, ...<number1>, <number2>, ... Yes 整数、浮点数或两者Integer, Float, or both 需要从中获取最小值的数字集The set of numbers from which you want the lowest value
[<number1>, <number2>, ...][<number1>, <number2>, ...] Yes 数组 - 整数、浮点数或两者Array - Integer, Float, or both 需要从中获取最小值的数字数组The array of numbers from which you want the lowest value
返回值Return value 类型Type 说明Description
<min-value><min-value> 整数或浮点数Integer or Float 指定的数字集或指定的数组中的最小值The lowest value in the specified set of numbers or specified array

示例Example

这些示例获取数字集和数组中的最小值:These examples get the lowest value in the set of numbers and the array:

min(1, 2, 3)
min(createArray(1, 2, 3))

并返回以下结果:1And return this result: 1

modmod

返回将两个数字相除后的余数。Return the remainder from dividing two numbers. 若要获取整数结果,请参阅 div()To get the integer result, see div().

mod(<dividend>, <divisor>)
参数Parameter 必须Required 类型Type 说明Description
<dividend><dividend> Yes 整数或浮点数Integer or Float 要用作 divisor 的被除数的数字The number to divide by the divisor
<divisor><divisor> Yes 整数或浮点数Integer or Float 用作 dividend 的除数的数字,但不能为 0。The number that divides the dividend, but cannot be 0.
返回值Return value 类型Type 说明Description
<modulo-result><modulo-result> 整数或浮点数Integer or Float 将第一个数字除以第二个数字后得到的余数The remainder from dividing the first number by the second number

示例Example

此示例将第一个数字除以第二个数字:This example divides the first number by the second number:

mod(3, 2)

并返回以下结果:1And return this result: 1

mulmul

返回将两个数字相乘得到的乘积。Return the product from multiplying two numbers.

mul(<multiplicand1>, <multiplicand2>)
参数Parameter 必须Required 类型Type 说明Description
<multiplicand1><multiplicand1> Yes 整数或浮点数Integer or Float 要与 multiplicand2 相乘的数字The number to multiply by multiplicand2
<multiplicand2><multiplicand2> Yes 整数或浮点数Integer or Float 要与 multiplicand1 相乘的数字The number that multiples multiplicand1
返回值Return value 类型Type 说明Description
<product-result><product-result> 整数或浮点数Integer or Float 将第一个数字乘以第二个数字后得到的乘积The product from multiplying the first number by the second number

示例Example

这些示例将第一个数字乘以第二个数字:These examples multiple the first number by the second number:

mul(1, 2)
mul(1.5, 2)

并返回以下结果:And return these results:

  • 第一个示例:2First example: 2
  • 第二个示例:3Second example 3

notnot

检查表达式是否为 false。Check whether an expression is false. 当表达式为 false 时返回 true,当表达式为 true 时返回 false。Return true when the expression is false, or return false when true.

not(<expression>)
参数Parameter 必须Required 类型Type 说明Description
<expression><expression> Yes 布尔Boolean 要检查的表达式The expression to check
返回值Return value 类型Type 说明Description
true 或 falsetrue or false 布尔Boolean 当表达式为 false 时返回 true。Return true when the expression is false. 当表达式为 true 时返回 false。Return false when the expression is true.

示例 1Example 1

这些示例检查指定的表达式是否为 false:These examples check whether the specified expressions are false:

not(false)
not(true)

并返回以下结果:And return these results:

  • 第一个示例:表达式为 false,所以此函数返回 trueFirst example: The expression is false, so the function returns true.
  • 第二个示例:表达式为 true,所以此函数返回 falseSecond example: The expression is true, so the function returns false.

示例 2Example 2

这些示例检查指定的表达式是否为 false:These examples check whether the specified expressions are false:

not(equals(1, 2))
not(equals(1, 1))

并返回以下结果:And return these results:

  • 第一个示例:表达式为 false,所以此函数返回 trueFirst example: The expression is false, so the function returns true.
  • 第二个示例:表达式为 true,所以此函数返回 falseSecond example: The expression is true, so the function returns false.

or

检查是否至少一个表达式为 true。Check whether at least one expression is true. 当至少一个表达式为 true 时返回 true,当两个表达式均为 false 时返回 false。Return true when at least one expression is true, or return false when both are false.

or(<expression1>, <expression2>)
参数Parameter 必须Required 类型Type 说明Description
, <expression1>, <expression2> Yes 布尔Boolean 要检查的表达式The expressions to check
返回值Return value 类型Type 说明Description
true 或 falsetrue or false 布尔Boolean 当至少一个表达式为 true 时返回 true。Return true when at least one expression is true. 当两个表达式均为 false 时返回 false。Return false when both expressions are false.

示例 1Example 1

这些示例检查是否至少一个表达式为 true:These examples check whether at least one expression is true:

or(true, false)
or(false, false)

并返回以下结果:And return these results:

  • 第一个示例:至少一个表达式为 true,所以此函数返回 trueFirst example: At least one expression is true, so the function returns true.
  • 第二个示例:两个表达式均为 false,所以此函数返回 falseSecond example: Both expressions are false, so the function returns false.

示例 2Example 2

这些示例检查是否至少一个表达式为 true:These examples check whether at least one expression is true:

or(equals(1, 1), equals(1, 2))
or(equals(1, 2), equals(1, 3))

并返回以下结果:And return these results:

  • 第一个示例:至少一个表达式为 true,所以此函数返回 trueFirst example: At least one expression is true, so the function returns true.
  • 第二个示例:两个表达式均为 false,所以此函数返回 falseSecond example: Both expressions are false, so the function returns false.

randrand

返回指定范围(仅包括起端在内)中的一个随机整数。Return a random integer from a specified range, which is inclusive only at the starting end.

rand(<minValue>, <maxValue>)
参数Parameter 必须Required 类型Type 说明Description
<minValue><minValue> Yes IntegerInteger 范围中的最小整数The lowest integer in the range
<maxValue><maxValue> Yes IntegerInteger 此函数可以返回的范围中的最大整数之后的整数The integer that follows the highest integer in the range that the function can return
返回值Return value 类型Type 说明Description
<random-result><random-result> IntegerInteger 从指定范围中返回的随机整数The random integer returned from the specified range

示例Example

此示例从指定范围内获取一个随机整数,不包括最大值:This example gets a random integer from the specified range, excluding the maximum value:

rand(1, 5)

并返回下列数字之一作为结果:1234And returns one of these numbers as the result: 1, 2, 3, or 4

rangerange

返回以指定整数开头的一个整数数组。Return an integer array that starts from a specified integer.

range(<startIndex>, <count>)
参数Parameter 必须Required 类型Type 说明Description
<startIndex><startIndex> Yes IntegerInteger 作为数组开头的第一项的整数值An integer value that starts the array as the first item
<count><count> Yes IntegerInteger 数组中的整数个数The number of integers in the array
返回值Return value 类型Type 说明Description
[<range-result>][<range-result>] ArrayArray 从指定索引开始的整数组成的数组The array with integers starting from the specified index

示例Example

此示例创建一个整数数组,从指定索引开始,并包含指定数目的整数:This example creates an integer array that starts from the specified index and has the specified number of integers:

range(1, 4)

并返回以下结果:[1, 2, 3, 4]And returns this result: [1, 2, 3, 4]

replacereplace

将子字符串替换为指定字符串,并返回结果字符串。Replace a substring with the specified string, and return the result string. 此函数区分大小写。This function is case-sensitive.

replace('<text>', '<oldText>', '<newText>')
参数Parameter 必须Required 类型Type 说明Description
<text><text> Yes StringString 包含要替换的子字符串的字符串The string that has the substring to replace
<oldText><oldText> Yes StringString 要替换的子字符串The substring to replace
<newText><newText> Yes StringString 替换字符串The replacement string
返回值Return value 类型Type 说明Description
<updated-text><updated-text> StringString 替换子字符串后得到的更新后字符串The updated string after replacing the substring

如果未找到子字符串,则返回原始字符串。If the substring is not found, return the original string.

示例Example

此示例查找“the old string”中的“old”子字符串并将“old”替换为“new”:This example finds the "old" substring in "the old string" and replaces "old" with "new":

replace('the old string', 'old', 'new')

并返回以下结果:"the new string"And returns this result: "the new string"

skipskip

删除集合开头的项,并返回所有其他项。Remove items from the front of a collection, and return all the other items.

skip([<collection>], <count>)
参数Parameter 必须Required 类型Type 说明Description
<collection><collection> Yes ArrayArray 要删除其项的集合The collection whose items you want to remove
<count><count> Yes IntegerInteger 要从开头删除的项数(一个正整数)A positive integer for the number of items to remove at the front
返回值Return value 类型Type 说明Description
[<updated-collection>][<updated-collection>] ArrayArray 删除指定项后得到的更新后的集合The updated collection after removing the specified items

示例Example

此示例从指定数组的开头删除一个项(数字 0):This example removes one item, the number 0, from the front of the specified array:

skip(createArray(0, 1, 2, 3), 1)

并返回包含剩余项的以下数组:[1,2,3]And returns this array with the remaining items: [1,2,3]

splitsplit

根据原始字符串中指定的分隔符字符,返回一个包含子字符串(以逗号分隔)的数组。Return an array that contains substrings, separated by commas, based on the specified delimiter character in the original string.

split('<text>', '<delimiter>')
参数Parameter 必须Required 类型Type 说明Description
<text><text> Yes StringString 根据原始字符串中指定的分隔符将分隔成子字符串的字符串The string to separate into substrings based on the specified delimiter in the original string
<delimiter><delimiter> Yes StringString 原始字符串中用作分隔符的字符The character in the original string to use as the delimiter
返回值Return value 类型Type 说明Description
[<substring1>,<substring2>,...][<substring1>,<substring2>,...] ArrayArray 一个数组,其中包含从原始字符串返回以逗号分隔的子字符串An array that contains substrings from the original string, separated by commas

示例Example

此示例根据作为分隔符的指定字符,从指定字符串创建具有子字符串的数组:This example creates an array with substrings from the specified string based on the specified character as the delimiter:

split('a_b_c', '_')

并将此数组作为以下结果返回:["a","b","c"]And returns this array as the result: ["a","b","c"]

startOfDaystartOfDay

返回时间戳中的天的开始时间。Return the start of the day for a timestamp.

startOfDay('<timestamp>', '<format>'?)
参数Parameter 必须Required 类型Type 说明Description
<timestamp><timestamp> Yes StringString 包含时间戳的字符串The string that contains the timestamp
<format><format> No StringString 单一格式的说明符自定义格式的模式Either a single format specifier or a custom format pattern. 时间戳的默认格式为“o”(yyyy-MM-ddT:mm:ss:fffffffK),这符合 ISO 8601 标准并保留了时区信息。The default format for the timestamp is "o" (yyyy-MM-ddTHH:mm:ss:fffffffK), which complies with ISO 8601 and preserves time zone information.
返回值Return value 类型Type 说明Description
<updated-timestamp><updated-timestamp> StringString 指定的时间戳,但从该天的零小时标记开始The specified timestamp but starting at the zero-hour mark for the day

示例Example

此示例查找以下时间戳中的天的开始时间:This example finds the start of the day for this timestamp:

startOfDay('2018-03-15T13:30:30Z')

并返回以下结果:"2018-03-15T00:00:00.0000000Z"And returns this result: "2018-03-15T00:00:00.0000000Z"

startOfHourstartOfHour

返回时间戳中的小时的开始时间。Return the start of the hour for a timestamp.

startOfHour('<timestamp>', '<format>'?)
参数Parameter 必须Required 类型Type 说明Description
<timestamp><timestamp> Yes StringString 包含时间戳的字符串The string that contains the timestamp
<format><format> No StringString 单一格式的说明符自定义格式的模式Either a single format specifier or a custom format pattern. 时间戳的默认格式为“o”(yyyy-MM-ddT:mm:ss:fffffffK),这符合 ISO 8601 标准并保留了时区信息。The default format for the timestamp is "o" (yyyy-MM-ddTHH:mm:ss:fffffffK), which complies with ISO 8601 and preserves time zone information.
返回值Return value 类型Type 说明Description
<updated-timestamp><updated-timestamp> StringString 指定的时间戳,但从该小时的零分钟标记开始The specified timestamp but starting at the zero-minute mark for the hour

示例Example

此示例查找以下时间戳中的小时的开始时间:This example finds the start of the hour for this timestamp:

startOfHour('2018-03-15T13:30:30Z')

并返回以下结果:"2018-03-15T13:00:00.0000000Z"And returns this result: "2018-03-15T13:00:00.0000000Z"

startOfMonthstartOfMonth

返回时间戳中的月份的开始时间。Return the start of the month for a timestamp.

startOfMonth('<timestamp>', '<format>'?)
参数Parameter 必须Required 类型Type 说明Description
<timestamp><timestamp> Yes StringString 包含时间戳的字符串The string that contains the timestamp
<format><format> No StringString 单一格式的说明符自定义格式的模式Either a single format specifier or a custom format pattern. 时间戳的默认格式为“o”(yyyy-MM-ddT:mm:ss:fffffffK),这符合 ISO 8601 标准并保留了时区信息。The default format for the timestamp is "o" (yyyy-MM-ddTHH:mm:ss:fffffffK), which complies with ISO 8601 and preserves time zone information.
返回值Return value 类型Type 说明Description
<updated-timestamp><updated-timestamp> StringString 指定的时间戳,但从该月第一天的零小时标记开始The specified timestamp but starting on the first day of the month at the zero-hour mark

示例Example

此示例查找以下时间戳中月份的开始时间:This example returns the start of the month for this timestamp:

startOfMonth('2018-03-15T13:30:30Z')

并返回以下结果:"2018-03-01T00:00:00.0000000Z"And returns this result: "2018-03-01T00:00:00.0000000Z"

startsWithstartsWith

检查字符串是否以特定的子字符串开头。Check whether a string starts with a specific substring. 当找到该子字符串时返回 true,找不到时返回 false。Return true when the substring is found, or return false when not found. 此函数不区分大小写。This function is not case-sensitive.

startsWith('<text>', '<searchText>')
参数Parameter 必须Required 类型Type 说明Description
<text><text> Yes StringString 要检查的字符串The string to check
<searchText><searchText> Yes StringString 要查找的起始字符串The starting string to find
返回值Return value 类型Type 说明Description
true 或 falsetrue or false 布尔Boolean 当找到起始子字符串时返回 true。Return true when the starting substring is found. 找不到时返回 false。Return false when not found.

示例 1Example 1

此示例检查“hello world”字符串是否以“hello”子字符串开头:This example checks whether the "hello world" string starts with the "hello" substring:

startsWith('hello world', 'hello')

并返回以下结果:trueAnd returns this result: true

示例 2Example 2

此示例检查“hello world”字符串是否以“greetings”子字符串开头:This example checks whether the "hello world" string starts with the "greetings" substring:

startsWith('hello world', 'greetings')

并返回以下结果:falseAnd returns this result: false

stringstring

返回值的字符串版本。Return the string version for a value.

string(<value>)
参数Parameter 必须Required 类型Type 说明Description
<value><value> Yes 任意Any 要转换的值The value to convert
返回值Return value 类型Type 说明Description
<string-value><string-value> StringString 指定的值的字符串版本The string version for the specified value

示例 1Example 1

此示例创建以下数字的字符串版本:This example creates the string version for this number:

string(10)

并返回以下结果:"10"And returns this result: "10"

示例 2Example 2

此示例为指定的 JSON 对象创建字符串并使用反斜杠字符 (\) 作为双引号 (") 的转义字符。This example creates a string for the specified JSON object and uses the backslash character (\) as an escape character for the double-quotation mark (").

string( { "name": "Sophie Owen" } )

并返回以下结果:"{ \\"name\\": \\"Sophie Owen\\" }"And returns this result: "{ \\"name\\": \\"Sophie Owen\\" }"

subsub

返回第一个数字减去第二个数字得到的结果。Return the result from subtracting the second number from the first number.

sub(<minuend>, <subtrahend>)
参数Parameter 必须Required 类型Type 说明Description
<minuend><minuend> Yes 整数或浮点数Integer or Float 要从中减去 subtrahend 的数字The number from which to subtract the subtrahend
<subtrahend><subtrahend> Yes 整数或浮点数Integer or Float 要从 minuend 中减去的数字The number to subtract from the minuend
返回值Return value 类型Type 说明Description
<result><result> 整数或浮点数Integer or Float 第一个数字减去第二个数字得到的结果The result from subtracting the second number from the first number

示例Example

此示例从第一个数字中减去第二个数字:This example subtracts the second number from the first number:

sub(10.3, .3)

并返回以下结果:10And returns this result: 10

substringsubstring

返回字符串中的字符,从指定的位置或索引开始。Return characters from a string, starting from the specified position, or index. 索引值从数字 0 开始。Index values start with the number 0.

substring('<text>', <startIndex>, <length>)
参数Parameter 必须Required 类型Type 说明Description
<text><text> Yes StringString 所需字符所在的字符串The string whose characters you want
<startIndex><startIndex> Yes IntegerInteger 一个等于或大于 0 的正数,需将其用作起始位置或索引值A positive number equal to or greater than 0 that you want to use as the starting position or index value
<length><length> Yes IntegerInteger 希望子字符串中具有的字符数(正数)A positive number of characters that you want in the substring
返回值Return value 类型Type 说明Description
<substring-result><substring-result> StringString 包含指定字符数的子字符串,从源字符串中的指定索引位置开始A substring with the specified number of characters, starting at the specified index position in the source string

示例Example

此示例基于指定的字符串从索引值 6 开始创建一个五字符的子字符串:This example creates a five-character substring from the specified string, starting from the index value 6:

substring('hello world', 6, 5)

并返回以下结果:"world"And returns this result: "world"

subtractFromTimesubtractFromTime

从时间戳中减去一定数目的时间单位。Subtract a number of time units from a timestamp. 另请参阅 getPastTimeSee also getPastTime.

subtractFromTime('<timestamp>', <interval>, '<timeUnit>', '<format>'?)
参数Parameter 必须Required 类型Type 说明Description
<timestamp><timestamp> Yes StringString 包含时间戳的字符串The string that contains the timestamp
<间隔><interval> Yes IntegerInteger 要减去的指定时间单位数The number of specified time units to subtract
<timeUnit><timeUnit> Yes StringString 间隔使用的时间单位:“秒”、“分钟”、“小时”、“日”、“周”、“月”、“年”The unit of time to use with interval: "Second", "Minute", "Hour", "Day", "Week", "Month", "Year"
<format><format> No StringString 单一格式的说明符自定义格式的模式Either a single format specifier or a custom format pattern. 时间戳的默认格式为“o”(yyyy-MM-ddT:mm:ss:fffffffK),这符合 ISO 8601 标准并保留了时区信息。The default format for the timestamp is "o" (yyyy-MM-ddTHH:mm:ss:fffffffK), which complies with ISO 8601 and preserves time zone information.
返回值Return value 类型Type 说明Description
<updated-timestamp><updated-timestamp> StringString 时间戳减去指定的时间单位数The timestamp minus the specified number of time units

示例 1Example 1

此示例从以下时间戳中减去 1 天:This example subtracts one day from this timestamp:

subtractFromTime('2018-01-02T00:00:00Z', 1, 'Day')

并返回以下结果:"2018-01-01T00:00:00:0000000Z"And returns this result: "2018-01-01T00:00:00:0000000Z"

示例 2Example 2

此示例从以下时间戳中减去 1 天:This example subtracts one day from this timestamp:

subtractFromTime('2018-01-02T00:00:00Z', 1, 'Day', 'D')

并使用可选的“D”格式返回以下结果:"Monday, January, 1, 2018"And returns this result using the optional "D" format: "Monday, January, 1, 2018"

taketake

返回集合开头的项。Return items from the front of a collection.

take('<collection>', <count>)
take([<collection>], <count>)
参数Parameter 必须Required 类型Type 说明Description
<collection><collection> Yes 字符串或数组String or Array 所需项所在的集合The collection whose items you want
<count><count> Yes IntegerInteger 从开头算起所需的项数(一个正整数)A positive integer for the number of items that you want from the front
返回值Return value 类型Type 说明Description
<subset> or [<subset>]<subset> or [<subset>] 分别为字符串或数组String or Array, respectively 一个字符串或数组,其中包含来自原始集合开头的指定数目的项A string or array that has the specified number of items taken from the front of the original collection

示例Example

这些示例从以下集合的开头获取指定的项数:These examples get the specified number of items from the front of these collections:

take('abcde', 3)
take(createArray(0, 1, 2, 3, 4), 3)

并返回以下结果:And return these results:

  • 第一个示例:"abc"First example: "abc"
  • 第二个示例:[0, 1, 2]Second example: [0, 1, 2]

ticksticks

返回指定时间戳的 ticks 属性值。Return the ticks property value for a specified timestamp. 一个“时钟周期”是 100 纳秒时间间隔。A tick is a 100-nanosecond interval.

ticks('<timestamp>')
参数Parameter 必须Required 类型Type 说明Description
<timestamp><timestamp> Yes StringString 时间戳的字符串The string for a timestamp
返回值Return value 类型Type 说明Description
<ticks-number><ticks-number> IntegerInteger 从指定的时间戳算起已过去的时钟周期数The number of ticks since the specified timestamp

toLowertoLower

返回小写格式的字符串。Return a string in lowercase format. 如果字符串中的某个字符没有对应的小写版本,则该字符在返回的字符串中保持原样。If a character in the string doesn't have a lowercase version, that character stays unchanged in the returned string.

toLower('<text>')
参数Parameter 必须Required 类型Type 说明Description
<text><text> Yes StringString 要以小写格式返回的字符串The string to return in lowercase format
返回值Return value 类型Type 说明Description
<lowercase-text><lowercase-text> StringString 采用小写格式的原始字符串The original string in lowercase format

示例Example

此示例将以下字符串转换为小写:This example converts this string to lowercase:

toLower('Hello World')

并返回以下结果:"hello world"And returns this result: "hello world"

toUppertoUpper

返回大写格式的字符串。Return a string in uppercase format. 如果字符串中的某个字符没有对应的大写版本,则该字符在返回的字符串中保持原样。If a character in the string doesn't have an uppercase version, that character stays unchanged in the returned string.

toUpper('<text>')
参数Parameter 必须Required 类型Type 说明Description
<text><text> Yes StringString 要以大写格式返回的字符串The string to return in uppercase format
返回值Return value 类型Type 说明Description
<uppercase-text><uppercase-text> StringString 采用大写格式的原始字符串The original string in uppercase format

示例Example

此示例将以下字符串转换为大写:This example converts this string to uppercase:

toUpper('Hello World')

并返回以下结果:"HELLO WORLD"And returns this result: "HELLO WORLD"

trimtrim

从字符串中删除前导和尾随空格,并返回更新后的字符串。Remove leading and trailing whitespace from a string, and return the updated string.

trim('<text>')
参数Parameter 必须Required 类型Type 说明Description
<text><text> Yes StringString 包含要删除的前导和尾随空格的字符串The string that has the leading and trailing whitespace to remove
返回值Return value 类型Type 说明Description
<updatedText><updatedText> StringString 原始字符串的更新后版本,其中不含前导或尾随空格An updated version for the original string without leading or trailing whitespace

示例Example

此示例从字符串“Hello World”中删除前导和尾随空格:This example removes the leading and trailing whitespace from the string " Hello World ":

trim(' Hello World  ')

并返回以下结果:"Hello World"And returns this result: "Hello World"

unionunion

返回一个集合,其中包含指定集合中的所有项。Return a collection that has all the items from the specified collections. 某个项只要出现在传递给此函数的任一集合中便会出现在结果中。To appear in the result, an item can appear in any collection passed to this function. 如果一个或多个项具有相同的名称,则具有该名称的最后一项将出现在结果中。If one or more items have the same name, the last item with that name appears in the result.

union('<collection1>', '<collection2>', ...)
union([<collection1>], [<collection2>], ...)
参数Parameter 必须Required 类型Type 说明Description
<collection1>, <collection2>, ...<collection1>, <collection2>, ... Yes 数组或对象,但不能为两者Array or Object, but not both 需要从中获取所有项的各个集合The collections from where you want all the items
返回值Return value 类型Type 说明Description
<updatedCollection><updatedCollection> 分别为数组或对象Array or Object, respectively 一个集合,其中包含指定集合中的所有项 - 无重复项A collection with all the items from the specified collections - no duplicates

示例Example

此示例获取以下集合中的“所有”项:This example gets all the items from these collections:

union(createArray(1, 2, 3), createArray(1, 2, 10, 101))

并返回以下结果:[1, 2, 3, 10, 101]And returns this result: [1, 2, 3, 10, 101]

uriComponenturiComponent

通过将 URL 不安全字符替换为转义字符来返回字符串的统一资源标识符 (URI) 编码版本。Return a uniform resource identifier (URI) encoded version for a string by replacing URL-unsafe characters with escape characters. 请使用此函数而非 encodeUriComponent()Use this function rather than encodeUriComponent(). 虽然这两个函数的工作方式相同,但首选 uriComponent()Although both functions work the same way, uriComponent() is preferred.

uriComponent('<value>')
参数Parameter 必须Required 类型Type 说明Description
<value><value> Yes StringString 要转换为 URI 编码格式的字符串The string to convert to URI-encoded format
返回值Return value 类型Type 说明Description
<encoded-uri><encoded-uri> StringString 带有转义字符的 URI 编码字符串The URI-encoded string with escape characters

示例Example

此示例创建以下字符串的 URI 编码版本:This example creates a URI-encoded version for this string:

uriComponent('https://contoso.com')

并返回以下结果:"http%3A%2F%2Fcontoso.com"And returns this result: "http%3A%2F%2Fcontoso.com"

uriComponentToBinaryuriComponentToBinary

返回统一资源标识符 (URI) 组件的二进制版本。Return the binary version for a uniform resource identifier (URI) component.

uriComponentToBinary('<value>')
参数Parameter 必须Required 类型Type 说明Description
<value><value> Yes StringString 要转换的 URI 编码字符串The URI-encoded string to convert
返回值Return value 类型Type 说明Description
<binary-for-encoded-uri><binary-for-encoded-uri> StringString URI 编码字符串的二进制版本。The binary version for the URI-encoded string. 二进制内容是 base64 编码的,并且由 $content 表示。The binary content is base64-encoded and represented by $content.

示例Example

此示例创建以下 URI 编码字符串的二进制版本:This example creates the binary version for this URI-encoded string:

uriComponentToBinary('http%3A%2F%2Fcontoso.com')

并返回以下结果:And returns this result:

"001000100110100001110100011101000111000000100101001100 11010000010010010100110010010001100010010100110010010001 10011000110110111101101110011101000110111101110011011011 110010111001100011011011110110110100100010"

uriComponentToStringuriComponentToString

返回统一资源标识符 (URI) 编码字符串的字符串版本,有效地对 URI 编码字符串进行解码。Return the string version for a uniform resource identifier (URI) encoded string, effectively decoding the URI-encoded string.

uriComponentToString('<value>')
参数Parameter 必须Required 类型Type 说明Description
<value><value> Yes StringString 要解码的 URI 编码字符串The URI-encoded string to decode
返回值Return value 类型Type 说明Description
<decoded-uri><decoded-uri> StringString URI 编码字符串的解码后的版本The decoded version for the URI-encoded string

示例Example

此示例创建以下 URI 编码字符串的解码后字符串版本:This example creates the decoded string version for this URI-encoded string:

uriComponentToString('http%3A%2F%2Fcontoso.com')

并返回以下结果:"https://contoso.com"And returns this result: "https://contoso.com"

utcNowutcNow

返回当前时间戳。Return the current timestamp.

utcNow('<format>')

另外,也可以使用 <format> 参数指定不同的格式。Optionally, you can specify a different format with the <format> parameter.

参数Parameter 必须Required 类型Type 说明Description
<format><format> No StringString 单一格式的说明符自定义格式的模式Either a single format specifier or a custom format pattern. 时间戳的默认格式为“o”(yyyy-MM-ddT:mm:ss:fffffffK),这符合 ISO 8601 标准并保留了时区信息。The default format for the timestamp is "o" (yyyy-MM-ddTHH:mm:ss:fffffffK), which complies with ISO 8601 and preserves time zone information.
返回值Return value 类型Type 说明Description
<current-timestamp><current-timestamp> StringString 当前日期和时间The current date and time

示例 1Example 1

假设今天的当前时间为 2018 年 4 月 15 日下午 1:00:00。Suppose today is April 15, 2018 at 1:00:00 PM. 此示例获取当前时间戳:This example gets the current timestamp:

utcNow()

并返回以下结果:"2018-04-15T13:00:00.0000000Z"And returns this result: "2018-04-15T13:00:00.0000000Z"

示例 2Example 2

假设今天的当前时间为 2018 年 4 月 15 日下午 1:00:00。Suppose today is April 15, 2018 at 1:00:00 PM. 此示例使用可选的“D”格式获取当前时间戳:This example gets the current timestamp using the optional "D" format:

utcNow('D')

并返回以下结果:"Sunday, April 15, 2018"And returns this result: "Sunday, April 15, 2018"

xmlxml

返回包含 JSON 对象的字符串的 XML 版本。Return the XML version for a string that contains a JSON object.

xml('<value>')
参数Parameter 必须Required 类型Type 说明Description
<value><value> Yes StringString 要转换的包含 JSON 对象的字符串The string with the JSON object to convert

该 JSON 对象必须只有一个根属性,该属性不能是数组。The JSON object must have only one root property, which can't be an array.
请使用反斜杠字符 (\) 作为双引号 (") 的转义字符。Use the backslash character (\) as an escape character for the double quotation mark (").

返回值Return value 类型Type 说明Description
<xml-version><xml-version> ObjectObject 指定的字符串或 JSON 对象的编码 XMLThe encoded XML for the specified string or JSON object

示例 1Example 1

此示例创建包含 JSON 对象的以下字符串的 XML 版本:This example creates the XML version for this string, which contains a JSON object:

xml(json('{ \"name\": \"Sophia Owen\" }'))

并返回以下结果 XML:And returns this result XML:

<name>Sophia Owen</name>

示例 2Example 2

假设具有以下 JSON 对象:Suppose you have this JSON object:

{
  "person": {
    "name": "Sophia Owen",
    "city": "Seattle"
  }
}

此示例创建包含以下 JSON 对象的字符串的 XML:This example creates XML for a string that contains this JSON object:

xml(json('{\"person\": {\"name\": \"Sophia Owen\", \"city\": \"Seattle\"}}'))

并返回以下结果 XML:And returns this result XML:

<person>
  <name>Sophia Owen</name>
  <city>Seattle</city>
<person>

xpathxpath

检查 XML 中是否存在与 XPath(XML 路径语言)表达式匹配的节点或值,并返回匹配的节点或值。Check XML for nodes or values that match an XPath (XML Path Language) expression, and return the matching nodes or values. XPath 表达式或单纯的“XPath”有助于在 XML 文档结构中导航,以便可以在 XML 内容中选择节点或计算值。An XPath expression, or just "XPath", helps you navigate an XML document structure so that you can select nodes or compute values in the XML content.

xpath('<xml>', '<xpath>')
参数Parameter 必须Required 类型Type 说明Description
<xml><xml> Yes 任意Any 要在其中搜索与 XPath 表达式值匹配的节点或值的 XML 字符串The XML string to search for nodes or values that match an XPath expression value
<xpath><xpath> Yes 任意Any 用来查找匹配的 XML 节点或值的 XPath 表达式The XPath expression used to find matching XML nodes or values
返回值Return value 类型Type 说明Description
<xml-node><xml-node> XMLXML 一个 XML 节点,当只有单个节点与指定的 XPath 表达式匹配时An XML node when only a single node matches the specified XPath expression
<value><value> 任意Any 来自一个 XML 节点的值,当只有单个值与指定的 XPath 表达式匹配时The value from an XML node when only a single value matches the specified XPath expression
[<xml-node1>, <xml-node2>, ...][<xml-node1>, <xml-node2>, ...]
-或--or-
[<value1>, <value2>, ...][<value1>, <value2>, ...]
ArrayArray 一个数组,其中包含与指定的 XPath 表达式匹配的 XML 节点或值An array with XML nodes or values that match the specified XPath expression

示例 1Example 1

在示例 1 的基础上,此示例查找与 <count></count> 节点匹配的节点并通过 sum() 函数添加这些节点值:Following on Example 1, this example finds nodes that match the <count></count> node and adds those node values with the sum() function:

xpath(xml(parameters('items')), 'sum(/produce/item/count)')

并返回以下结果:30And returns this result: 30

示例 2Example 2

对于此示例,两个表达式都查找与指定参数(其中通过命名空间包括了 XML)中的 <location></location> 节点匹配的节点。For this example, both expressions find nodes that match the <location></location> node, in the specified arguments, which include XML with a namespace. 表达式使用反斜杠字符 (\) 作为双引号 (") 的转义字符。The expressions use the backslash character (\) as an escape character for the double quotation mark (").

  • 表达式 1Expression 1

    xpath(xml(body('Http')), '/*[name()=\"file\"]/*[name()=\"location\"]')

  • 表达式 2Expression 2

    xpath(xml(body('Http')), '/*[local-name()=\"file\" and namespace-uri()=\"http://contoso.com\"]/*[local-name()=\"location\"]')

下面是参数:Here are the arguments:

  • 以下 XML,其中包括 XML 文档命名空间 xmlns="http://contoso.com"This XML, which includes the XML document namespace, xmlns="http://contoso.com":

    <?xml version="1.0"?> <file xmlns="http://contoso.com"> <location>Paris</location> </file>
    
  • 以下任一 XPath 表达式:Either XPath expression here:

    • /*[name()=\"file\"]/*[name()=\"location\"]

    • /*[local-name()=\"file\" and namespace-uri()=\"http://contoso.com\"]/*[local-name()=\"location\"]

下面是与 <location></location> 节点匹配的结果节点:Here is the result node that matches the <location></location> node:

<location xmlns="https://contoso.com">Paris</location>

示例 3Example 3

在示例 3 的基础上,此示例在 <location></location> 节点中查找值:Following on Example 3, this example finds the value in the <location></location> node:

xpath(xml(body('Http')), 'string(/*[name()=\"file\"]/*[name()=\"location\"])')

并返回以下结果:"Paris"And returns this result: "Paris"

后续步骤Next steps

对于可以在表达式中使用的系统变量列表,请参阅系统变量For a list of system variables you can use in expressions, see System variables.