0

I have been trying to split a string into an array of each line \n As this doesn't work I tried replacing replace(outputs('Compose_6'),'\r\n','@') with a view to then splitting on @.

I have searched the internet and tried various things but nothing seems to work.

Can someone explain how to do this?

Thanks in advance

yogibear
  • 320
  • 2
  • 13
  • Can you show us your input data? Please add it as the json that goes into your action where you’re trying to split. – Skin Feb 09 '23 at 20:07

1 Answers1

0

Using split(variables('string var'),'\n') expression, you can split string into array. By default logic app will add an extra black slash to original back slash. So suggesting you to change expression in code view as mentioned above.

  • I have created logic app as shown below, enter image description here
  • In first initialize variable action, taken a string variable with text as shown below
Hello
Test split functionality
Using logic apps

enter image description here

  • Next initialize variable action, using a array variable and assigning value using expression as split(variables('string var'),'\n'). Make sure you dont have double back slash added in code view. Only one back slash should be there when you see it in code view. enter image description here Code view: enter image description here
  • The output of logic app can be shown below,
  • enter image description here enter image description here enter image description here Refer this SO thread.
vijaya
  • 1,525
  • 1
  • 2
  • 6