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
remove string Dynamically
Moderators: chulett, rschirm, roy
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
"You can never have too many knives" -- Logan Nine Fingers
Hi,
As craig said your example seems to have a changing algorithym
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?
As craig said your example seems to have a changing algorithym
in the above example you supplied there are several different logics for extracting the data0000000002
000000000
~0000000009~1001~
~VENDOR~0000000138~1001~
~VENDOR~0020009816~2001~
~0020009816~2100~
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
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
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
If you use a BASIC Transformer stage the following expression will work.
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.
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.
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.