0

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

user3165854
  • 1,505
  • 8
  • 48
  • 100

1 Answers1

2

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|']", "")]
Simon Karlsson
  • 4,090
  • 22
  • 39