代码之家  ›  专栏  ›  技术社区  ›  gtx911

Dataweave-字符串数组删除方括号

  •  1
  • gtx911  · 技术社区  · 7 年前

    我明白了 字符串数组 :

    ["HELLO","WORLD"]

    我想输出相同的,但没有方括号:

    "HELLO","WORLD"

    我如何用 在骡子里?

    1 回复  |  直到 7 年前
        1
  •  1
  •   utechtzs    7 年前

    可能的解决方案(评论中提到@jerney)

    %dw 1.0
    %output application/java
    
    %var input = "[\"HELLO\", \"WORLD\"]"
    ---
    input[1..-2]
    

    使用正则表达式:

    %dw 1.0
    %output application/java
    
    %var input = "[\"HELLO\", \"WORLD\"]"
    ---
    input replace /^\[|\]$/ with ""
    

    %dw 1.0
    %output application/java
    
    %var input = "[\"HELLO\", \"WORLD\"]"
    ---
    input replace "[" with "" replace "]" with ""
    
    推荐文章