Dataweave - String array remove square brackets

Viewed 3132

I get this string array:

["HELLO","WORLD"]

And I want to output the same but without square brackets:

"HELLO","WORLD"

How can I replace or transform this with Dataweave in Mule?

1 Answers

Possible solutions (credit to @jerney in the comments)

Using index manipulation:

%dw 1.0
%output application/java

%var input = "[\"HELLO\", \"WORLD\"]"
---
input[1..-2]

Using regex:

%dw 1.0
%output application/java

%var input = "[\"HELLO\", \"WORLD\"]"
---
input replace /^\[|\]$/ with ""

Using simple replacement:

%dw 1.0
%output application/java

%var input = "[\"HELLO\", \"WORLD\"]"
---
input replace "[" with "" replace "]" with ""
Related