Trimming a string - rather than a character

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
sjordery
Premium Member
Premium Member
Posts: 202
Joined: Thu Jun 08, 2006 5:58 am

Trimming a string - rather than a character

Post by sjordery »

Hi All,

Probably a simple one for you gurus out there, but it's been a long day here...

Basically, I have the following row:
<OpenTag attritbute"888"><SecondOpenTag>
As part of my processing, I am splitting up the XML and don't want the second open tag...

So, what I want to do is:

Code: Select all

Trim(Input.Field,'<SecondOpenTag>','A')
But of course, this is no good as trim only does a single char. Any easy way to do this...? I wanted to avoid server job/routine and don't know C++.

Many thanks in advance.
S
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

If server job is acceptable, use EREPLACE() to replace the string.
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
crouse
Charter Member
Charter Member
Posts: 204
Joined: Sun Oct 05, 2003 12:59 pm
Contact:

Post by crouse »

Is there only one occurence of "<SecondOpenTab>" in the string?

if so, you could do SOMETHING like:
right(string,index(string,"<SecondOpenTab>",1) -1) : left(len(string) - index(string,"<SecondOpenTab>",1) + 15)

In essence, you clip off the right and left side and concat them together.

If you have more than one occurance to remove... you'll need to do this over and over. ick!
Craig Rouse
Griffin Resouces, Inc
www.griffinresources.com
sjordery
Premium Member
Premium Member
Posts: 202
Joined: Thu Jun 08, 2006 5:58 am

Post by sjordery »

Great - thanks very much for ther pointers. :)

Cheers,
S
Post Reply