Do you want to split the string between two characters using Power Automate flow? Then, this Power Automate tutorial is for you. Here, I will show you how to split a string between two characters using Power Automate with different examples.
Scenario:
Recently, I got a requirement where I needed to split strings between two characters using Power Automate flow. For example, if we have values like below
PowerPlatforms@PowerAutomate&PowerBI
Once the string has been extracted, which is presented between two characters, it displays the value below:
PowerAutomate
Here, I will explain two different ways of splitting the string between two characters using the Split() function and IndexOf expression in Power Automate with static and dynamic examples.
Now, we will create a flow to split the string between two characters using Power Automate flow.
Split String between two characters using Power Automate
Let us see how to split a string between two characters using Power Automate flow,
Example – 1: (Using Split function())
In this example, I will show you how to split a string between two characters using the Split() function in Power Automate
Step-1:
Create an instant cloud flow with a manual trigger, add a new step, choose to compose data operation, and pass the below value as input.
PowerPlatforms@PowerAutomate&PowerBI
Step-2:
And another compose data operation, to split the first character presented in the string input.
first(split(outputs('String_Values_with_characters'),'&'))
Step-3:
Add a new step and select the compose data operation to split the second character presented in the string input.
Step-4:
save and run the flow; here, in the Output of the compose data operation, we can see the expected result.
This is how to split a string between two characters using the Split() function in Power Automate.
Example – 2:
In this example, I will show you how to split a string between two characters using the IndexOf expression in Power Automate flow.
Step-1:
Create an instant cloud flow with a manual trigger, add a new step, choose the compose data operation, and pass the below value as input.
PowerPlatforms@PowerAutomate&PowerBI
Step-2:
Add a compose data operation and use the below expression to get the @ position
add(int(indexOf(outputs('String_Values_with_two_characters'), '@')), 1)
Step-3:
To get the & position, add another compose data operation and use the below expression.
int(indexOf(outputs('String_Values_with_two_characters'), '&'))
Step-4:
To get the difference between two characters, add a compose data operation and use the below formula:
sub(outputs('Get_Index_of_&'),outputs('Get_Indexof_@'))
Step-5:
To get the extracted string, add a compose data operation and use the below substring () expression.
substring(outputs('String_Values_with_two_characters'),outputs('Get_Indexof_@'),outputs('Get_Last_Index'))
Step-6:
save and run the flow by selecting the run flow option. Once the flow runs successfully like below, We can see the expected output in the extracted string compose data operation.
This is how to split a string between two characters using the IndexOf expression in Power Automate.
Example – 3:
In this example, I will show you how to split a string between two characters from the SharePoint list text column using the Split() function in Power Automate flow.
Here, I am going to use the below Technologies SharePoint list, Consisting of
- Technology – default title column
- StringWithTwoCharacters – Single line of text type
Now, we will create a flow to split a string between two characters for the StringWithTwoCharacters column presented in the SharePoint list.
Step-1:
Create an instant cloud flow with a manual trigger, select Get items action from action triggers, and configure the required parameters.
- Site Address – select the SharePoint site address from the dropdown
- List Name – choose the SharePoint list. Here I have selected my technology list
Step-2:
Add a new step, choose an Apply to each control, and pass the value from the dynamic content
Add Another compose data operation is to split the first character presented in the StringWithTwoCharacters field in the SharePoint list.
first(split(items('Apply_to_each')?['StringWithTwoCharacters'],'&'))
Add another compose data operation to split the second character presented in the StringWithTwoCharacters field
last(split(outputs('Compose'),'@'))
Now, we will update the StringWithTwoCharacters field after extracting the string value between two characters.
For that, Add a new step, choose the Update item action from action triggers, and provide the below parameters:
- Site Address – select the SharePoint site address from the dropdown
- List Name – choose the SharePoint list. Here, I have selected my technology list
- ID – choose the ID from dynamic content values
In the StringWithTwoCharacters field, pass the outputs of the previous compose data operation
Outputs('Split_second_character')
Step-3:
save and run the flow once the flow runs successfully like below:
We can see it extracts and updates the string between two characters in the StringWithTwoCharacters field presented in the SharePoint list.
This is how to split a string between two characters from the SharePoint list text column using the Split() function using flow.
Example – 4:
In this example, I will show you how to split a string between two characters from the SharePoint list text column using the IndexOf expression in Power Automate flow.
Here also, I am going to use the below Technologies SharePoint list with different values.
Step-1:
Create an instant cloud flow with a manual trigger, select Get items action from action triggers, and configure the required parameters.
- Site Address – select the SharePoint site address from the dropdown
- List Name – choose the SharePoint list. Here I have selected my technology list
Step-2:
Add a new step, choose an Apply to each control, and pass the value from the dynamic content
Add Another compose data operation to get the @ position presented in the StringWithTwoCharacters field in the SharePoint list.
add(int(indexOf(items('Apply_to_each')?['StringWithTwoCharacters'],'@')),1)
To get the & position, add another compose data operation and use the below expression.
int(indexOf(items('Apply_to_each')?['StringWithTwoCharacters'], '&'))
To get the difference between two characters, add a compose data operation and use the below formula:
sub(outputs('Get_Index_of_second_character'),outputs('Get_Index_of_first_character'))
To get the extracted string, add a compose data operation and use the below substring () expression.
substring(items('Apply_to_each')?['StringWithTwoCharacters'],outputs('Get_Index_of_first_character'),outputs('Get_last_index'))
Now, we will update the StringWithTwoCharacters field after extracting the string value between two characters.
For that, Add a new step, choose the Update item action from action triggers, and provide the below parameters:
- Site Address – choose the SharePoint site address from the dropdown
- List Name – select the SharePoint list. Here, I have selected my technology list
- ID – from dynamic content value select the ID
In the StringWithTwoCharacters field, pass the outputs of the previous compose data operation (i.e.Extracted string value)
outputs('Extracted_string_value')
Step-3:
save and run the flow once the flow runs successfully like below:
We can see it extracts and updates the string between two characters in the StringWithTwoCharacters field presented in the SharePoint list.
This is how to split a string between two characters from the SharePoint list text column using the IndexOf expression using flow.
Split string between multiple characters using Power Automate
Let us see how to split a string between multiple characters using Power Automate flow,
Example – 1: (static way)
In this example, I will show you how to split a string between multiple characters using the Split() function in Power Automate
- Create an instant cloud flow with a manual trigger, add a new step, choose compose data operation, and pass the below value as input.
PowerPlatforms@PowerAutomate&PowerBI&PowerApps&PowerVitualAgent&PowerPages
- Another compose data operation is to split the first character presented in the string input.
first(split(outputs('String_Value'),'&'))
- Add a new step and select the compose data operation to split the second character presented in the input string.
last(split(outputs('String_Value'),'@'))
- Add a compose data operation to split the values from the previous compose data operation.
split(outputs('Second_Split'),'&')
- To display the output value based on the index value, pass the below expression; here, I have passed the index value as [3].
outputs('Last_Split')[3]
- Save and run the flow by clicking on the run flow option. Here, in the Output of the compose data operation, we can see the expected result.
This is how to split a string between multiple characters using the Split() function in Power Automate.
Example – 2: (dynamic way)
In this example, I will show you how to split a string between multiple characters from the SharePoint list text column using the Split() function in Power Automate flow.
Here, I am going to use the below Technologies SharePoint list, which consists of
- Technology – default title column
- StringWithMultipleCharacters – Multi line of text type
Step-1:
Create an instant cloud flow with a manual trigger, select Get items action from action triggers, and configure the required parameters.
- Site Address – select the SharePoint site address from the dropdown
- List Name – choose the SharePoint list. Here I have selected my technology list
Step-2:
Add a new step, choose an Apply to each control, and pass the value from the dynamic content
And another compose data operation, to split the first character presented in the string input.
first(split(items('Apply_to_each')?['StringWithMultipleCharacters'],'&'))
Add a new step and select the compose data operation to split the second character presented in the input string.
last(split(items('Apply_to_each')?['StringWithMultipleCharacters'],'@'))
Add a compose data operation to split the values from the previous compose data operation.
split(outputs('Second_Split'),'&')
Now, we will update the StringWithMultipleCharacters field based on the index value
For that, Add a new step, choose the Update item action from action triggers, and provide the below parameters:
- Site Address – select the SharePoint site address from the dropdown
- List Name – choose the SharePoint list. Here, I have selected my technology list
- ID – choose the ID from dynamic content values
In the StringWithMultipleCharacters field, pass the outputs of the previous compose data operation with the index value; here, I have passed the index value as [2].
outputs('Last_Split')[2]
Step-3:
save and run the flow once the flow runs successfully like below:
we can see it extracts and updates the string in the StringWithMultipleCharacters field presented in the SharePoint list.
This is how to split a string between multiple characters from the SharePoint list text column using the Split() function in the Power Automate flow
Example-3: (static way)
In this example, I will show you how to split a string between multiple invalid characters using the Split() function in Power Automate
Step-1:
Create an instant cloud flow with a manual trigger, add a new step, choose the compose data operation, and pass the below value as input.
PowerPlatforms@PowerAutomate%PowerBI$PowerApps#PowerVitualAgent*PowerPages|PowerFX
Step-2:
Add a new step and select the compose data operation to replace the invalid characters presented in the input string with a comma, use the below expression
replace(replace(replace(replace(replace(replace(outputs('String_Value'),'@',','),'%',','),'$',','),'#',','),'|',','),'*',',')
Step-3:
Add a compose data operation, to split the values from the previous compose data operation.
split(outputs('Replaced_String_value'),',')
Step-4:
To display the output value based on the index value, pass the below expression; here, I have passed the index value as [1].
outputs('Split_values')[1]
Step-5:
save and run the flow by clicking on the run flow option. Here, in the Output of the compose data operation, we can see the expected result.
This is how to split a string between multiple invalid characters using the Split() function in Power Automate
Example-4:(dynamic way)
In this example, I will show you how to split a string between multiple invalid characters from the SharePoint list text column using a split() function in Power Automate flow.
Here also, I am going to use the below Technologies SharePoint list with different invalid characters.
Step-1:
Create an instant cloud flow with a manual trigger, select Get items action from action triggers, and configure the required parameters.
- Site Address – select the SharePoint site address from the dropdown
- List Name – choose the SharePoint list. Here I have selected my technology list
Step-2:
Add a new step, choose an Apply to each control, and pass the value from the dynamic content
Add a new step and select the compose data operation to replace the invalid characters presented in the input string with a comma, use the below expression
replace(replace(replace(replace(replace(replace(items('Apply_to_each')?['StringWithMultipleCharacters'],'@',','),'%',','),'$',','),'#',','),'|',','),'*',',')
Add a compose data operation to split the values from the previous compose data operation.
split(outputs('Replace_invalid_characters'),',')
Now, we will update the StringWithMultipleCharacters field based on the index value
For that, Add a new step, choose the Update item action from action triggers, and provide the below parameters:
- Site Address – select the SharePoint site address from the dropdown
- List Name – choose the SharePoint list. Here, I have selected my technology list
- ID – choose the ID from dynamic content values
In the StringWithMultipleCharacters field, pass the outputs of the previous compose data operation based on the index value
outputs('Split_the_string_value')[1]
Step-3:
save and run the flow once the flow runs successfully like below:
we can see it extracts and updates the string in the StringWithMultipleCharacters field presented in the SharePoint list.
This is how to split a string between multiple invalid characters from the SharePoint list text column using a split() function in Power Automate flow.
Conclusion
I hope you got an idea of how to split a string between two characters in Power Automate flow.
Here, I have explained two different ways of splitting the string between two characters using the Split() function and IndexOf expression in Power Automate with static and dynamic examples.
You may also like:
- Convert a String to an Integer in Power Automate
- Convert String to GUID in Power Automate
- Check if an item exists in a SharePoint list using Power Automate
- How to Split a String between Multiple Characters in Power Automate?
After working for more than 15 years in Microsoft technologies like SharePoint, Office 365, and Power Platform (Power Apps, Power Automate, and Power BI), I thought will share my SharePoint expertise knowledge with the world. Our audiences are from the United States, Canada, the United Kingdom, Australia, New Zealand, etc. For my expertise knowledge and SharePoint tutorials, Microsoft has been awarded a Microsoft SharePoint MVP (9 times). I have also worked in companies like HP, TCS, KPIT, etc.