Express Yourself: String Functions Examples

This page contains additional examples of all the String functions available in Microsoft Flow. This page will be updated periodically to include more examples created by the community.

concat

Example 1
This example concatenates the value from 2 columns located in different SharePoint lists:
concat(triggerBody()?['Address_x0020_email'],triggerBody()?['Email_x0020_main_x0020_by']?['Value'])
Source: Example 1

Example 2
This example concatenates the string “Open Registration” with the value from the Term column in an Excel file:
concat('Open Registration',items('Apply_to_each')?['Term'])
Source: Example 2

Example 3
This example concatenates 2 variables of String type. The variables are named VariableA and VariableB:
concat(variables('VariableA'),variables('VariableB'))
Source: Example 3

substring

Example 1
This example retrieves the first 19 characters of the sunset time that’s originally in the following format: 2018-04-16T23:46:50+00:00. The output is 2018-04-16T23:46:50 since the substring function removed +00:00. Thanks to  SandyU for this example.
substring(body('Get_forecast_for_today')?['responses']?['almanac']?['sunset'],0,19)
Source: Example 1

Example 2
This example retrieves the characters after the word “Job” in the email subject. To get the “Job” word, a Compose action uses the following expression: last(split(triggerBody()?['Subject'],'Job:'))
In the next Compose action, the substring() function retrieves the words from the first Compose action starting at index 0, followed by the length of characters from the previous Compose action: substring(outputs('Compose'),0,sub(length(outputs('Compose')),3))
Source: Example 2
Note: the length() and last() functions are discussed in this post. The split() function is discussed at the end of this post. As for the sub() function, this will be discussed in a future post about Math functions in Microsoft Flow.

replace

Example 1
In this example, the user wants to remove bullet points from a list of items contained in a column named Description:
replace(triggerBody()?['Description'],'•','')
Source: Example 1

Example 2
In this example, the user wants to add a border to the table created in the Create HTML table action. By using the replace function, the ‘table’ tag is replaced with ‘table border=”1″‘, adding a 1px border to the entire HTML table. See the expression below:
replace
Source: Example 2
Note: had to use an image to show the replace expression for example 2. This is due to the expression having HTML tags, which WordPress removes.

guid

toLower

Example 1
In this example, the user wants to convert the value from a choice column named EmployeeOnboardingType to lowercase. See the expression below:
toLower(triggerBody()?['EmployeeOnboardingType']?['Value'])
Source: Example 1

toUpper

indexOf

Example 1
In this example, the user wants to retrieve several keywords from the body of an email, including Start time. The expression uses the indexOf() function to retrieve the information pertaining to Start time from the “HTML to text” action.
indexOf(body('HTML_to_text'),'Start time')
Source: Example 1

Example 2
In this example, the user wants to retrieve the First Name from a user’s Display Name. To retrieve the First Name, a Compose action is used to build an expression with the indexOf() function: indexOf(body('Get_user_profile_(V1)')?['DisplayName'],' '). This retrieves the information before the space between the First Name and Last Name.
In the next Compose action, the substring() function retrieves the information from the DisplayName property in the “Get user profile (V1)” action starting at index 0, followed by the length from the previous Compose action: substring((body('Get_user_profile_(V1)')?['DisplayName'],0,outputs('Compose'))
Source: Example 2

lastIndexOf

Example 1
In this example, the user wants to retrieve the Account Number information from the body of an email. The expression starts with the substring() function, which runs through the text returned in the “HTML to text” action. For the startIndex of the substring() function, the expression retrieves the last index of the word Account Number using the lastIndexOf() function and then adds 15 using the add() function. Finally, the length of the substring is 8, since that’s the number or characters used for the Account Number. This is the full expression:
substring(body('HTML_to_text'),add(lastIndexOf(body('HTML_to_text'),'Account Number'), 15), 8)
Source: Example 1

startsWith

Example 1

endsWith

Example 1

split

Example 1

Leave a comment