lets say you have an array called ips:
[
"[\"185.241.208.232",
"194.26.192.64",
"171.25.193.25",
"\"]"
]
how would I filter out the [" and "] out of the array.
the array that enters the watchlist should look like:
[
"185.241.208.232",
"194.26.192.64",
"171.25.193.25"
]
i need to do this without using a for loop to look at every item for the \ (as the actual list is very long and it'll make the logic app run for some time). i happen to know the \ exists at the start and end of the list.
You don't need to use For each
loops to achieve the desired result - this is very inefficient.
You need to use only 2 actions:
Select
- to remove unnecessary characters from each item of your array:Code View:
{
"inputs": {
"from": [
"[\"185.241.208.232",
"194.26.192.64",
"171.25.193.25",
"\"]"
],
"select": "@replace(replace(replace(item(), '[', ''), ']', ''), '\"', '')"
}
}
Filter array
- to remove empty items from the array:Code View:
{
"inputs": {
"from": "@body('Select')",
"where": "@greater(length(item()), 0)"
}
}