Searching string in PL/I.

HLASM for MVS. PL/I for MVS & Enterprise PL/I for z/OS.
Post Reply
MariaJames
New Member
Posts: 2
Joined: Mon Jun 29, 2015 10:55 am

Searching string in PL/I.

Post by MariaJames »

I have a variable declared in PL/I as character. Variable may have 15,000 length of data. The data can be mix of differnt characters inclusing special signs. I need to search the occurance of 3 consecutive numbers in this set of 15,000 characters. Ccan you please guide on how can I do it?

Thanks.
User avatar
Robert Sample
Global Moderator
Global Moderator
Posts: 1895
Joined: Fri Jun 28, 2013 1:22 am
Location: Dubuque Iowa
United States of America

Re: Searching string in PL/I.

Post by Robert Sample »

Are you looking for three digits in a row or do you want a particular 3-digit value?
enrico-sorichetti
Global Moderator
Global Moderator
Posts: 826
Joined: Wed Sep 11, 2013 3:57 pm

Re: Searching string in PL/I.

Post by enrico-sorichetti »

if You know what You are searching for - 987 for example - a simple

Code: Select all

where = index(your_string,'987')
will do

otherwise if You are searching for three consecutive numeric chars You will need a two stage approach ...

Code: Select all

work_string=translate(your_string,'$$$$$$$$$$','0123456789') 
where = index(work_string,'$$$'')
the $ is a character that must NOT exist in your_string
cheers
enrico
When I tell somebody to RTFM or STFW I usually have the page open in another tab/window of my browser,
so that I am sure that the information requested can be reached with a very small effort 8-)
Post Reply

Create an account or sign in to join the discussion

You need to be a member in order to post a reply

Create an account

Not a member? register to join our community
Members can start their own topics & subscribe to topics
It’s free and only takes a minute

Register

Sign in

Return to “Assembler & PL/I.”