简体   繁体   English

如何在Mule Dataweave转换中使用正则表达式替换特殊字符?

[英]How to replace special character using regex in Mule Dataweave transformation?

Suppose I have an XML file of details of employee such as id, name and address and now I want to convert it into JSON file and before the conversation I want to replace specified special character (- , /) with blank space in address field of json document 假设我有一个员工详细信息的XML文件,例如id,name和address,现在我想将它转换为JSON文件,在谈话之前我想用地址字段中的空格替换指定的特殊字符( - ,/)。 json文件

below are my Dataweave transformation code 下面是我的Dataweave转换代码

%dw 1.0
%output application/json
---
payload map ((payload01 , indexOfPayload01) -> {
    Id: payload01 .d as :string,
    Name: payload01.Name as :string, 
    Address: payload01.Address replace /(?)/ with " "
})

So what should I write within replace /()/ function to replace specials character , - and / with blank space ? 那么我应该在replace /()/函数中写什么来替换特殊字符 -/空格

请尝试以下代码

Address: payload01.Address replace /([\-\,\/])/ with " "

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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