Page 1 of 1

replace consecutive spaces by one space

Posted: Thu Apr 03, 2014 2:03 pm
by harryhome
Hi need to replace consecutive space by one single space.

Code: Select all

Input string:  "THIS      IS     TEST   STRING"

Desired out put: "THIS IS TEST STRING"
is there any way to do this in transformer in 7.5

[Note - Code Tags added to preserve whitespace - Andy]

Posted: Thu Apr 03, 2014 2:50 pm
by chulett
Those two strings look the same to me. :wink: [Andy, Andy, Andy]

The forum software removes any 'extra' spaces automatically... you'd need to use

Code: Select all

 tags in order to preserve them in any posted examples. 

Did you check your documentation for the permutations of the "Trim" function? Don't recall what it supported back in the 7.5 days.

Posted: Thu Apr 03, 2014 3:12 pm
by ray.wurlod
Trim() function with a single argument (the string on which to operate)removes leading, trailing and redundant whitespace characters.

Posted: Thu Apr 03, 2014 3:15 pm
by chulett
Knew it did on the Server side of the world, wasn't sure enough about the Parallel side to make that same assertation without access to my docs.

Posted: Mon Apr 07, 2014 12:23 am
by moalik
Hi Harry,

You can use the "CompactWhiteSpace(%string%)" function in the transformer and pass the column as input to it.

Example: CompactWhiteSpace(DSLink.Designation)

if the data is in format :
Input string: "THIS IS TEST STRING"
Desired out put: "THIS IS TEST STRING"