How to Extract substring from text using Power Automate Desktop?

This Power Automate Desktop tutorial will show us how to get a substring from a string using Power Automate Desktop. I will show you examples of how to extract substring from text using Power Automate Desktop.

To extract a substring from a string we will use two methods:

  • Using the Get Subset action
  • Using Crop text action

Extract substring from text Power Automate Desktop (Using the Get subtext action)

Here we will see how to extract a substring from the text in Power Automate Desktop using the ‘Get subtext action’.

Get subtext action will get the subtext of a text value specifying the start index and length in Power Automate Desktop. Some of the use case

  • The text should be of fixed length
  • The substring should be of a fixed length.

For example, we have a text i.e. ‘I am Alex Stwart. My age is 45’ from here we need to retrieve ‘Alex Stwart’. Here in the Get subset, we will pass the starting index as 4, and the length of the substring is 12. After running this flow, we will get the ‘Alex stwart’.

Step 1: Open Power Automate Desktop, click on +New flow -> provide the flow name, and click Create button.

Extract substring from text Power Automate Desktop

Step 2: We will add a variable, where we will assign the string; for this, expand the variable section -> drag and drop the Set variable action to canvas. Then provide the flow information:

  • Value: Provide the value like below.
How to extract substring from text Power Automate Desktop

Step 3: Now we will extract the substring; for this, expand the Text section, then drag and drop the ‘Get subset’ action. Then provide the below information:

  • Original text: click on variable icon {x}, and then select the string variable
  • Start index: Select the ‘Character Position’.
  • Character Position: Provide the character position on 4.
  • Length: Select the Number of chars.
  • Number of characters: Provide 12.
How to extract substring from text using Power Automate Desktop

Step 4: Now run the flow by clicking on the run button. Once the flow runs successfully, then on the right side under the Flow variable -> double click on the ‘Subtext’ variable. You can see the output below:

How to extract substring from text using Microsoft Power Automate Desktop

This is how we can get the substring from text using ‘Get subtext’ action in Power Automate Desktop

See also  Power Automate Multiple Conditions [With 19 useful examples]

Extract substring from text Power Automate Desktop (Using the Crop action)

Here we will see how to extract a substring from the text in Power Automate Desktop using the Crop action.

The crop action gets a text value that occurs before, after, or between the specified text flags in a given text.

For example, we have a text, i.e., ‘I am Alex Stwart. My age is 45’, from here we need to retrieve ‘Alex Stwart’. Here we will use the Crop action; in this action, we will pass the start flag as ‘I am’ and the end flag as ‘.’ to get the text ‘Alex Stwart’.

Step 1: Open Power Automate Desktop, click on +New flow -> provide the flow name, and click on Create button.

Extract substring from text Power Automate Desktop

Step 2: We will add a variable, where we will assign the string, for this, expand the variable section -> drag and drop the Set variable action to canvas. Then provide the flow information:

  • Value: Provide the value like below.
How to extract substring from text Power Automate Desktop

Step 3: We will extract the string; drag and drop the ‘Crop text’ action for this. Then provide the below information:

  • Original text: click on variable icon {x}, and then select the string variable
  • Mode: Select the ‘Get text between two flags’ option.
  • Start flag: Provide the start flag as I am.
  • End flag: Provide the end flag as ‘.’
How to crop substring from text using Microsoft Power Automate Desktop

Step 4: Now run the flow by clicking on the run button. Once the flow runs successfully, then on the right side under the Flow variable -> double click on the ‘CroppedText’ variable. You can see the output below:

How to crop substring from text using Power Automate Desktop

This is how to get a substring from text using the ‘Crop’ action in Power Automate Desktop.

See also  The template language function 'length' expects its parameter to be an array or a string Power Automate

Conclusion

In this Power Automate Desktop tutorial, we saw how to get the substring from text in Power Automate Desktop.

You may also like:

>