Power Automate expression中的 string 相关公式

Power Automate 现阶段还不能使用上Power Fx,所以我们可以使用Azure Logicapp 中的functions

string中的常用的一些function如下:

ps: 如有问号则为optional选项

concat

Combine two or more strings, and return the combined string

Concat可以把2个/2个以上的string结合到一起,并且返回一个结合之后的string

Function: concat('<text1>', '<text2>', ...)

Example: concat('Hello', 'World')

Output: Hello World

endWith

Check whether a string ends with a specific substring. Return true when the substring is found, or return false when not found. This function is not case-sensitive.

检查你的string是否是以特定的有个substring做结尾。 返回值为bool(true/false) 如果找到结束为substring则返回true, 未找到substring则返回false。 这个方法不是大小写敏感。

Function: endsWith('<text>', '<searchText>')

Example: endsWith('hello world', 'world')

Output: true

formatNumber

Return a number as a string that's based on the specified format.

基于特定的格式将一个number返回一个string

Function: formatNumber(<number>, <format>, <locale>?)

Example:

formatNumber(1234567890, '0,0.00', 'en-us')

formatNumber(17.35, 'C2')

Output:

1,234,567,890.00

$17.35

guid

Generate a globally unique identifier (GUID) as a string, for example, "c2ecc88d-88c8-4096-912c-d6f2e2b138ce":

 生成 一个 string类型的GUID

Function:

guid()

guid('<format>')   ps: GUID的remark各代表什么

Example: guid('P')

Output: "(c2ecc88d-88c8-4096-912c-d6f2e2b138ce)"

indexOf

Return the starting position or index value for a substring. This function is not case-sensitive, and indexes start with the number 0.

返回substring在string中的index 值。 这个function不是大小写敏感功能,index 开始数为0

Function: indexOf('<text>', '<searchText>')

Example: indexOf('hello world', 'world')

Output: 6

lastIndexOf

Return the starting position or index value for the last occurrence of a substring. This function is not case-sensitive, and indexes start with the number 0.

返回开始位置或者在string中出现的substring的index值。 非大小写敏感,index开始值为0

Function: lastIndexOf('<text>', '<searchText>')

如果text 值是空,则返回-1

如果text和searchText两者皆为空,则返回0

如果searchText是空,则text的总长度减1

Example:

lastIndexOf('hello world hello world', 'world')

lastIndexOf('hello world hello world', '')

Output:

18

22

length

Return the number of items in a collection.

返回在一个string中所有字节总和

Function: length('<collection>')

Example: length('abcd')

Output: 4

replace

Replace a substring with the specified string, and return the result string. This function is case-sensitive.

在string中把一部分旧字段用新字段代替掉。 大小写敏感功能

Function: replace('<text>', '<oldText>', '<newText>')

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

Output: the new string

split

Return an array that contains substrings, separated by commas, based on the specified delimiter character in the original string.

把string中的所有字段按照指定的方式分割开,并且输出为array

Function: split('<text>', '<delimiter>')

Example: split('a_b_c', '_')

Output: ["a","b","c"]

startWith

Check whether a string starts with a specific substring. Return true when the substring is found, or return false when not found. This function is not case-sensitive.

检查string中是否以substring作为开始, 返回值为bool(true/false), 非大小写敏感

Function: startsWith('<text>', '<searchText>')

Example: startsWith('hello world', 'hello')

Output: true

substring

Return characters from a string, starting from the specified position, or index. Index values start with the number 0.

从string中,按照指定的index和长度返回相应的字段。  index值从0开始

Function: substring('<text>', <startIndex>, <length>)

Example: substring('hello world', 6, 5)

Output: world

toLower

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.

把string中的所有字符改为小写

Function: toLower('<text>')

Example: toLower('Hello World')

Output: hello world

toUpper

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.

把string中的所有字符改为大写

Function: toUpper('<text>')

Example: toUpper('Hello World')

Output: HELLO WORLD

trim

Remove leading and trailing whitespace from a string, and return the updated string.

移除string当中的所有空格

Function: trim('<text>')

Example: trim(' Hello World  ')

Output: Hello World

原文地址:https://www.cnblogs.com/TheMiao/p/14618978.html