cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
scottgm23
Level: Power Up

[Solved] - Extract last n-characters from Form input

Hello everyone, 

 

I have a pretty simple requirement but I can't seem to figure out how to achieve this in Flow. 

 

I have a form where a user is requested to input an ID number with or without the leading characters, such as:

 

XYZ000000333222

333222

XYZ333222

XYZ000333222

 

I am only interested in the last 6 characters of their input (333222 in this example) as I can modify the string later in SharePoint when I do a DB lookup. Using a regular expression ((.{6})\s*$) this is very simple but I'm not sure how to achieve this using a substring or split or some other expressions within Flow.

2019-03-27_20-05-27.jpg

 

Regex.jpg

 

1 ACCEPTED SOLUTION

Accepted Solutions
Super User
Super User

Re: Extract last n-characters from Form input

Hi @scottgm23 , thank you for your post.

I have simulated your form input by using "Compose Input" below:Capture-423.png

sub(length(outputs('Compose_Input')), 6)
substring(outputs('Compose_Input'), int(outputs('Compose_Number_Of_Characters_In_Input')), 6)

Regardless of what the input is, this method will get you the last 6 digits of the ID number.

 

If you have found my post helpful, please mark thumbs up.

 

Any other questions, just ask.

 

Thanks, Alan


Did I answer your question? Mark my post as a solution!

Proud to be a Flownaut!


View solution in original post

3 REPLIES 3
Super User
Super User

Re: Extract last n-characters from Form input

Hi @scottgm23 , thank you for your post.

I have simulated your form input by using "Compose Input" below:Capture-423.png

sub(length(outputs('Compose_Input')), 6)
substring(outputs('Compose_Input'), int(outputs('Compose_Number_Of_Characters_In_Input')), 6)

Regardless of what the input is, this method will get you the last 6 digits of the ID number.

 

If you have found my post helpful, please mark thumbs up.

 

Any other questions, just ask.

 

Thanks, Alan


Did I answer your question? Mark my post as a solution!

Proud to be a Flownaut!


View solution in original post

scottgm23
Level: Power Up

Re: Extract last n-characters from Form input

Many thanks @AlanPs1 , I appreciate you taking the time to help.

 

After some more trial and error, I figured out that I needed to calculate the index value for the substring and then arrived at the same solution as you(well almost). I didn't specify INT in the last subsubstring value but it worked either way. 

 

Solution.jpg

Highlighted
Super User
Super User

Re: Extract last n-characters from Form input

That's great @scottgm23 .

int() not always required but Flow tends to output to string unless told otherwise so it's a safer option a lot of the time.

I'm glad you have it working!

 

Happy Flowing!

Thanks, Alan


Did I answer your question? Mark my post as a solution!

Proud to be a Flownaut!


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 (5,130)