remove string Dynamically

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
marpadga18
Premium Member
Premium Member
Posts: 96
Joined: Fri Aug 20, 2010 8:51 am

remove string Dynamically

Post by marpadga18 »

Hi All

I am trying to get the data between the string dynamically which is '~'. Any ideas would be appreciated.

Source
0000000002
000000000
~0000000009~1001~
~VENDOR~0000000138~1001~
~VENDOR~0020009816~2001~
~0020009816~2100~

Target required
0000000002
000000000
0000000009
0000000138
0020009816
0020009816


Thanks for the help
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Start by looking into the Field() function but... clarify your rules / requirements for us.
Last edited by chulett on Mon Jan 13, 2014 10:51 am, edited 1 time in total.
-craig

"You can never have too many knives" -- Logan Nine Fingers
roy
Participant
Posts: 2598
Joined: Wed Jul 30, 2003 2:05 am
Location: Israel

Post by roy »

Hi,
As craig said your example seems to have a changing algorithym
0000000002
000000000
~0000000009~1001~
~VENDOR~0000000138~1001~
~VENDOR~0020009816~2001~
~0020009816~2100~
in the above example you supplied there are several different logics for extracting the data
rows 1+2 first and only field
rows 3 & 6 2nd field using the ~ delimiter
rows 4+5 3rd field using the ~ delimiter

so the question is:
what is the actual logic for extracting the numbers?
Roy R.
Time is money but when you don't have money time is all you can afford.

Search before posting:)

Join the DataStagers team effort at:
http://www.worldcommunitygrid.org
Image
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

If you use a BASIC Transformer stage the following expression will work.

Code: Select all

MatchField(InLink.TheString, "~0N0N0X", 2)

This returns the first wholly numeric string in the original string.
The tilde in the pattern is unrelated to tildes in the source string. The first part of the pattern ("~0N") is matched by any number of non-numeric characters, the second part of the pattern ("0N") is matched by any number of entirely numeric characters, and the third part of the pattern ("0X") is matched by anything.
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