简体   繁体   中英

Dataweave - String array remove square brackets

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?

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 ""

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM