cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Armin0815
Regular Visitor

Cleaning up strings - best way?

I'm creating a workflow that depends on the contents of a string to control its' behaviour. 

 

Example strings would be:

  • [Report][Classification:Blue] 20220831 Something happened
  • [Warning][Report][Classification:Red] 20220830 Something serious happened

My first approach is to break down the string to get it into an array. For this I replace all occurences of '][', '[', ']' with '%' and then split it based on '%':

  • Initialize variable INPUTSTRING
  • Compose a string manupulation:
    replace (variables('INPUTSTRING'),'][','%')
  • Set INPUTSTRING to OUTPUTS
  • Compose a string manupulation:
    replace (variables('INPUTSTRING'),'[','%')
  • Set INPUTSTRING to OUTPUTS2
  • Compose a string manupulation:
    replace (variables('INPUTSTRING'),']','%')
  • Set INPUTSTRING to OUTPUTS3
    etc.

It works, but it looks and handles extremely cumbersome. Am I missing a streamlined but still understandable process?

Armin0815_0-1661941256720.png

 

1 ACCEPTED SOLUTION

Accepted Solutions
ekarim2020
Super User
Super User

Hi @Armin0815 ,

 

You havent't shown the output you want to get?

For example:

Input:  [Report][Classification:Blue] 20220831 Something happened

Output: Report Classification:Blue  20220831 Something happened

 

You can nest multiple functions together in one action, for example:

 

 

replace(replace(replace(variables('INPUTSTRING'), '][','%'), ']','%'), '[','%')

 

 


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

View solution in original post

2 REPLIES 2
ekarim2020
Super User
Super User

Hi @Armin0815 ,

 

You havent't shown the output you want to get?

For example:

Input:  [Report][Classification:Blue] 20220831 Something happened

Output: Report Classification:Blue  20220831 Something happened

 

You can nest multiple functions together in one action, for example:

 

 

replace(replace(replace(variables('INPUTSTRING'), '][','%'), ']','%'), '[','%')

 

 


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

Armin0815
Regular Visitor

Thanks, nesting wasn't on my radar. Doesn't tick the "easy to read" category, but I think I can live with that as it works just fine!

Helpful resources

Announcements
Power Automate News & Announcements

Power Automate News & Announcements

Keep up to date with current events and community announcements in the Power Automate community.

Microsoft 365 Conference – December 6-8, 2022

Microsoft 365 Conference – December 6-8, 2022

Join us in Las Vegas to experience community, incredible learning opportunities, and connections that will help grow skills, know-how, and more.

Power Automate Community Blog

Power Automate Community Blog

Check out the latest Community Blog from the community!

Users online (2,997)