Searching string in PL/I.

HLASM for MVS. PL/I for MVS & Enterprise PL/I for z/OS.
Previous topicNext topic

Topic Author
New Member
Posts: 2
Joined: Mon Jun 29, 2015 10:55 am

Searching string in PL/I.

Post by MariaJames » Wed Jul 22, 2015 7:55 pm

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?


User avatar

Robert Sample
Global Moderator
Global Moderator
Posts: 1379
Joined: Fri Jun 28, 2013 1:22 am
Location: Dubuque Iowa
Zodiac: Virgo

Re: Searching string in PL/I.

Post by Robert Sample » Wed Jul 22, 2015 8:10 pm

Are you looking for three digits in a row or do you want a particular 3-digit value?

Global Moderator
Global Moderator
Posts: 892
Joined: Wed Sep 11, 2013 3:57 pm

Re: Searching string in PL/I.

Post by enrico-sorichetti » Thu Jul 23, 2015 1:01 am

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

where = index(work_string,'$$$'')
the $ is a character that must NOT exist in your_string

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-)

Previous topicNext topic

Return to “Assembler & PL/I.”