cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
bclarkuncc
Level: Powered On

MS Flow Variable Remove Last Character In a String

I am trying to remove the last character from a string variable in MSFlow.  I've tried several things but so far no luck.  Any feedback on the best way to do this?  

1 ACCEPTED SOLUTION

Accepted Solutions
Super User
Super User

Re: MS Flow Variable Remove Last Character In a String

@bclarkuncc 

This should help....

In my example, I have a string called varString.

The expression that I used to get all but the last character is:

substring(variables('varString'),0,add(length (variables('varString')),-1))

 

The substring function allows me to extract part of a string - I specify where to start (position 0) and how many characters I want.

To find how many characters to take, I use the length expression to give me the string length and subtract one for the result.

 

Substr1.jpgSubstr2.jpg

 

 

If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

Scott

View solution in original post

3 REPLIES 3
Super User
Super User

Re: MS Flow Variable Remove Last Character In a String

There are a few ways to do this, but nearly all of them revolve around utilizing the Compose action. See the Functions documentation for Flow, and the Using Functions within Flow using the Compose Action blog post for some further ideas on how it can be used.  

If you could provide an expanded screenshot of your Flow and steps, and of any detailed error messages you're receiving we could likely better assist you.

If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up. THANKS!

Super User
Super User

Re: MS Flow Variable Remove Last Character In a String

@bclarkuncc 

This should help....

In my example, I have a string called varString.

The expression that I used to get all but the last character is:

substring(variables('varString'),0,add(length (variables('varString')),-1))

 

The substring function allows me to extract part of a string - I specify where to start (position 0) and how many characters I want.

To find how many characters to take, I use the length expression to give me the string length and subtract one for the result.

 

Substr1.jpgSubstr2.jpg

 

 

If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

Scott

View solution in original post

Community Support Team
Community Support Team

Re: MS Flow Variable Remove Last Character In a String

Hi @bclarkuncc ,

 

The methods provided by Scott are valid, and you could also consider using take() function.

take(variables('String'),sub(length(variables('String')),1))

Image reference:

10.PNG11.PNG

There are a lot of functions in WDL function that can be used to process strings. For more details, please refer to Online doc:

https://docs.microsoft.com/en-us/azure/logic-apps/workflow-definition-language-functions-reference

 

Best Regards,

Community Support Team _ Barry
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
firstImage

Power Platform Online Conference

Join us for the first ever Power Platform Online Conference!

firstImage

Incoming: New and improved badges!

Look out for new contribution recognition badges coming SOON!

firstImage

New & Improved Power Automate Community Cookbook

We've updated and improved the layout and uploading format of the Power Automate Cookbook!

thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Power Platform World Tour

Find out where you can attend!

seventhimage

Webinars & Video Gallery

Watch & learn from the Power Automate Community Video Gallery!

Top Solution Authors
Top Kudoed Authors
Users online (6,318)