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

Community site session details

Session Id : 0E5S23YAvkDWjYINaWAhHH
Power Automate - Building Flows
Answered

Is it possible to replace special characters in an array?

Like (0) ShareShare
ReportReport
Posted on 2 Jan 2024 12:38:25 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

 

 

  • stefanstick Profile Picture
    26 on 03 Jan 2024 at 13:49:49
    Re: Is it possible to replace special characters in an array?

    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.'.


  • rzaneti Profile Picture
    4,096 Super User 2025 Season 2 on 03 Jan 2024 at 12:55:44
    Re: Is it possible to replace special characters in an array?

    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 03 Jan 2024 at 10:31:28
    Re: Is it possible to replace special characters in an array?

    @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.

  • Verified answer
    rzaneti Profile Picture
    4,096 Super User 2025 Season 2 on 02 Jan 2024 at 18:32:47
    Re: Is it possible to replace special characters in an array?

    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/ 

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

Announcing our 2025 Season 2 Super Users!

A new season of Super Users has arrived, and we are so grateful for…

Paul Stork – Community Spotlight

We are honored to recognize Paul Stork as our July 2025 Community…

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 497 Super User 2025 Season 2

#2
David_MA Profile Picture

David_MA 436 Super User 2025 Season 2

#3
Riyaz_riz11 Profile Picture

Riyaz_riz11 244 Super User 2025 Season 2