How to leave text with a specified number of characters from the left or right.(Power Automate Desktop)
Learn how to leave text from the left or right with a specified number of characters.
Overall flow

Robin(for copy and paste)
It can be copied and pasted into Power Automate Desktop.
SET Text TO $'''abcde''' SET LeaveLength TO 2 IF LeaveLength <= Text.Length THEN Text.GetSubtext.GetSubtextFromStartTo Text: Text NumberOfChars: LeaveLength Subtext=> Subtext Text.GetSubtext.GetSubtextFrom Text: Text CharacterPosition: Text.Length - LeaveLength Subtext=> Subtext2 END
Steps
First, prepare variables.
Variable | Name(Example) |
---|---|
Target text. | %Text% |
Number of characters to leave. | %LeaveLength% |

Next, put in place an "If" to check for errors.
Parameter | Value |
---|---|
First operand | %LeaveLength% |
Operator | Less than or equal to (<=) |
Second operand | %Text.Length% |

Put in place "Get Subtext" in "If".
To leave from the left, set the following.
Parameter | Value |
---|---|
Original text | %Text% |
Start Index | Start of text |
Length | Number of chars |
Number of chars | %LeaveLength% |

To remove from the right, set the following.
Parameter | Value |
---|---|
Original text | %Text% |
Start Index | Character position |
Character position | %Text.Length - LeaveLength% |
Length | End of text |

When the subflow to run, the text of the result is set to the variable produced in "Get Subtext".

For those who want to learn Power Automate Desktop effectively
The information on this site is now available in an easy-to-read e-book format.
Or Kindle Unlimited (unlimited reading).

You willl discover how to about basic operations.
By the end of this book, you will be equipped with the knowledge you need to use Power Automate Desktop to streamline your workflow.
Discussion
New Comments
No comments yet. Be the first one!