简体   繁体   中英

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

below are my Dataweave transformation code

%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 ?

请尝试以下代码

Address: payload01.Address 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