Removing multiple spaces from a string

As presented your string appears to have no multiple spaces, but to have spaces at the start and end. To solve the problem you asked, I would use a Java Snippet node configured to replace your incoming column:

String str = c_MyColumnReferenceHere.trim();  //Incoming column
while (str.contains("  ")){  //2 spaces
    str = str.replace("  ", " "); //(2 spaces, 1 space)
}
c_resultColumn = str; //Result column

Steve

1 Like