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
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.'.
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!
@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.
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:
I'm also starting an empty array just to store the result after the replaces:
Then you add an 'Apply to each' just to iterate all values inside the original array:
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:
At the end of the flow, we have a 'Compose' just to display the final result of the clean array:
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:
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/
Michael E. Gernaey
497
Super User 2025 Season 2
David_MA
436
Super User 2025 Season 2
Riyaz_riz11
244
Super User 2025 Season 2