Can you use OR in REPLACE in Anypoint Mule

1.2k Views Asked by At

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

1

There are 1 best solutions below

0
On

You can make it a little bit shorter by using replaceAlland a regex like this:

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