Page 1 of 1

remove string Dynamically

Posted: Mon Jan 13, 2014 7:28 am
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

Posted: Mon Jan 13, 2014 8:10 am
by chulett
Start by looking into the Field() function but... clarify your rules / requirements for us.

Posted: Mon Jan 13, 2014 10:42 am
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?

Posted: Mon Jan 13, 2014 4:11 pm
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.