简体   繁体   中英

Can you use OR in REPLACE in Anypoint Mule

I am using Anypoint Studio 6.1 and Mule 3.8.1 and want to replace \\n with new line and then remove \\r, \\t, \\ from the payload text.

I can do this like:

#[payload.replace('\\n', System.getProperty('line.separator')).replace('\\r', "").replace('\\t', "").replace('\\', "")]

Is there a way to use OR or something similar for the checks on \\r, \\t, \\ to reduce the code?

Thanks

您可以使用replaceAll和这样的正则表达式将其缩短一点:

#[payload.replace('\\n', System.getProperty('line.separator')).replaceAll("[\r|\t|']", "")]

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