Difference between Trim() and TrimLeadingTrailing()

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
gowrishankar_h
Participant
Posts: 42
Joined: Wed Dec 26, 2012 1:13 pm

Difference between Trim() and TrimLeadingTrailing()

Post by gowrishankar_h »

Hi All,

One basic question what the difference between function Trim() and Trimleadingtrailing()..I hope both do the same job.

Thanks,
Gowri
priyadarshikunal
Premium Member
Premium Member
Posts: 1735
Joined: Thu Mar 01, 2007 5:44 am
Location: Troy, MI

Post by priyadarshikunal »

Trim() can do the job of TrimLeadingTrailing() however vice-versa is not true.

TrimLeadingTrailing() will remove leading and trailing spaces. However Trim() without any specifier will remove leading and trailing spaces along with redundant spaces within the string.

The syntax for Trim() is trim(<string>,<trim char>, <trim option>)

Trim has a few options and by default D is used and space is used by default for trim char. If option B is selected then it will remove leading and trailing characters. Please refer the manual for more details.
Priyadarshi Kunal

Genius may have its limitations, but stupidity is not thus handicapped. :wink:
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

In summary, they will behave differently on strings such as

Code: Select all

"     HERMAN      MUNSTER       "
TrimLeadingTrailing() will produce

Code: Select all

"HERMAN      MUNSTER"
Trim() with no other arguments will produce

Code: Select all

"HERMAN MUNSTER"
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 »

Or...

Code: Select all

"     1313   Mockingbird     Lane          "
:wink:
-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 »

:D
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Post Reply