replace consecutive spaces by one space

Post questions here relative to DataStage Enterprise/PX Edition for such areas as Parallel job design, Parallel datasets, BuildOps, Wrappers, etc.

Moderators: chulett, rschirm, roy

Post Reply
harryhome
Participant
Posts: 112
Joined: Wed Oct 18, 2006 7:10 am

replace consecutive spaces by one space

Post 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]
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post 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.
Last edited by chulett on Mon Apr 07, 2014 7:10 am, edited 1 time in total.
-craig

"You can never have too many knives" -- Logan Nine Fingers
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Trim() function with a single argument (the string on which to operate)removes leading, trailing and redundant whitespace characters.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post 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.
-craig

"You can never have too many knives" -- Logan Nine Fingers
moalik
Participant
Posts: 39
Joined: Thu Sep 15, 2011 8:15 am
Location: Melbourne

Post 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"
Mohsin Khan
Datastage Consultant
Post Reply