How to search for a specific string within an input string

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
saraswati
Premium Member
Premium Member
Posts: 149
Joined: Thu Feb 28, 2008 4:25 pm

How to search for a specific string within an input string

Post by saraswati »

Hi

I have a input str OPT_STRING="AN3 AY1 B34 B35 C67 DG7 FE1 FE9 FQ3 IKC JB9 JL9 KG7 K05 LZ4 MX0 M15 NK5 NT7 NW9 OSH QB5 QPX UE0 UW6 U1C U19 U2E U77 VC5 VH9 VS7 V73 WD1 WD2 WD7 Z49 1SB 19C 19I 40U 6HM 7HM 8MZ 9MZ"


Now the requirement is:
IF Option code VN9 or VNL exists in the source field OPT_STRING send 'X' else send blank

Note: There is a space between any two option code in the input string i.e.
AN3 AY1, after 3 there is a space.

How to search VN9 and VNL within the input string OPT_STRING?
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Index()
-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 »

An even more cunning plan - one that cannot fail - is to search for the delimited string.

Code: Select all

If Index(" " : OPT_STRING : " ", " " : OptionCode : " ", 1) Then "X" Else " "
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 »

Which I would have mentioned if there was any chance for an inadvertent substring match... in this case there isn't, so left that one alone. :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 »

I'm channelling Baldrick today.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
saraswati
Premium Member
Premium Member
Posts: 149
Joined: Thu Feb 28, 2008 4:25 pm

Post by saraswati »

Index function worked fine for my requirement. Thanks everyone for their help :)
kishore2456
Participant
Posts: 47
Joined: Mon May 07, 2007 10:35 pm

Post by kishore2456 »

how about matches ?
FD
Post Reply