cancel
Showing results for 
Search instead for 
Did you mean: 

How to replace multiple Spaces with the single space by using graphical mapping

0 Kudos

Hi Experts,

Could you please give the suggestions on below requirement.

From the sender system we are getting the data with multiple spaces in between (Ex: SAP      PI    Mapping) . And we have to replace that multiple spaces with one space.(Ex: SAP PI Mapping). Even we don't know how many spaces are coming from sender side. Scenario is JDBC to sFTP.

Thank you in Advance.

Regards,

Anusha.

Accepted Solutions (1)

Accepted Solutions (1)

justin_santhanam
Active Contributor
0 Kudos

Hi Anusha,

There are so many different ways, this is just one way ( otherways are using regex etc..)

Code:


return datainput.trim().replaceAll(" +", " ");

Let us know if it doesn't help!

0 Kudos

Thank u Justin. It is working 🙂

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi Anusha

Use this logic.

while(input.contains("  ")){

  input = input.replaceAll("  ", " ");

  }

input -------> you input field.

input.contains("  ") -----> Use 2 spaces between double quotes.

input.replaceAll("  "," ") ---------> replace 2 spaces with 1 space. First double quotes will have 2 spaces, and second double quotes will have 1 space.

Regards

Osman

0 Kudos

Thank u Osman. 🙂