web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Is it possible to repl...
Power Automate
Answered

Is it possible to replace special characters in an array?

(0) ShareShare
ReportReport
Posted on by 26

Hello,

I found several topics to replace an several special characters in an string.

But I would like to replace several special characters in an variable of the type array.

The array with the special characters is like this: createArray('"','*',':','<','>','?','/','\','|')

 

The array in which I would like to replaced the special characters is the 

outputs from the getrows(V2) Connector / Aktion.

 

Do You have an example?
Thx

 

 

Categories:
I have the same question (0)
  • Verified answer
    rzaneti Profile Picture
    4,241 Super User 2025 Season 2 on at

    Hi @stefanstick ,

     

    If I understood it correctly, you have an array of strings, some of them containing special characters that must be replaced. To achieve it, you will need to first iterate your array by using the 'Apply to each' action, and inside its block, perform the replace operation. 

     

    Here is a quick example with an array of strings containing semicolons:

    rzaneti_0-1704219227690.png

     

    I'm also starting an empty array just to store the result after the replaces:

    rzaneti_1-1704219269683.png

     

     

    Then you add an 'Apply to each' just to iterate all values inside the original array:

    rzaneti_2-1704219298286.png

     

    Inside the 'Apply to each block', you will have a compose (where the replace is performed) and an 'Append to array variable', which will add the transformed string to the new array. For the replace task, we are using a very simple expression just to substitute the semicolons for dashes:

    rzaneti_3-1704219469493.png

     

    At the end of the flow, we have a 'Compose' just to display the final result of the clean array:

    rzaneti_4-1704219506289.png

     

    Alternatively, if you want to perform this replace task for each of the existing special characters in another array, you can use a similar logic:

    rzaneti_6-1704220047155.png

     

     

    In yellow,  you have the special characters array, created before the 'Apply to each' loop. Inside the loop, you will need to create a compose to store the value of the current item mapped of the array of strings to be reviewed. Right after that, in pink, you insert a new 'Apply to each', where you will map the special characters array.

     

    In blue, you are testing if the current iterated special character exists in the string to be reviewed, If yes, the replace process will be performed, but at this time, instead of just replace semicolons, it is replacing the item() value, which corresponds to the current special character. 

     

    This approach has a limitation: if the string in the array has more than 1 special character, it will be inserted as a duplicate in the 'clean array'. With some additional validations, you can prevent it to happen. 

     

    I'm also sharing some articles related to the actions used in this answer for further reference.

     

    Let me know if it works for you or if you need any additional help!

     

    -------------------------------------------------------------------------
    If this is the answer for your question, please mark the post as Solved.
    If this answer helps you in any way, please give it a like.

    http://digitalmill.net/ 
    https://www.linkedin.com/in/raphael-haus-zaneti/ 

  • stefanstick Profile Picture
    26 on at

    @rzaneti 
    Many thanks. It is very helpful. The ongoing Problem is, that my Array is dynamicly filled from a SQL Get Rows (V2) Action. Then I have always the situation, when I want to replace the Array, that I have to convert it into a string.

  • rzaneti Profile Picture
    4,241 Super User 2025 Season 2 on at

    Hi @stefanstick ,

     

    Could you please share an image your 'Get rows (V2)' output, so we can see exactly how does your array look like? Make sure to remove any sensitive data before sharing it 🙂

     

    Also, feel free to share a sample of what is your expected output after the replace operation!

  • stefanstick Profile Picture
    26 on at

    Hi @rzaneti ;

    here is the Error Code:

     

    Unable to process template language expressions in action 'Variable_initialisieren_2' inputs at line '0' and column '0': 'The template language function 'replace' expects its first parameter 'string' to be a string. The provided value is of type 'Array'. Please see https://aka.ms/logicexpressions#replace for usage details.'.


Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 501 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 323 Moderator

#3
abm abm Profile Picture

abm abm 237 Most Valuable Professional

Last 30 days Overall leaderboard