Searching



IBM's Command List programming language & Restructured Extended Executor

Searching

Postby poornimayeleswarapu » Fri Oct 22, 2010 3:35 pm

Hi all,

My requirement is like this:

i am searhing for a string in a member. And i got the starting postion of that string into a variable S. Now from the starting postion i want to read the characters till the end of the line. Is there any way to do this.

For example:

My search string is abc. so in 5 lines i am going to search for this string.

hhhhhhhh
yyyyyyyyyy
bbbbbbbbbbbb
rrrtrtabctyuttt
ttyyuuuiiiooo

so my search string is there in 4th line and starting position of a in abc is 7 which is present in S. So using this starting postion can i just pull abctyuttt to a variable and display the value.

Can any one help me in achieving this. Please let me know if you need any more info.

Thanks.
poornimayeleswarapu
 
Posts: 8
Joined: Tue Oct 19, 2010 12:46 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Searching

 

Re: Searching

Postby MrSpock » Fri Oct 22, 2010 3:58 pm

Once you know the position of the search string within the entire string, you can just use a PARSE command to extract the data.

Some other options would be to use SUBSTR or RIGHT.
User avatar
MrSpock
Global moderator
 
Posts: 810
Joined: Wed Jun 06, 2007 9:37 pm
Location: Raleigh NC USA
Has thanked: 0 time
Been thanked: 2 times

Re: Searching

Postby poornimayeleswarapu » Fri Oct 22, 2010 4:17 pm

hi,

Can you please tell me how do i parse it.. i mean i want to know the syntax
would parse pull work?

Thanks.
poornimayeleswarapu
 
Posts: 8
Joined: Tue Oct 19, 2010 12:46 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Searching

Postby poornimayeleswarapu » Fri Oct 22, 2010 4:22 pm

Hi,

Thank you. I made it work. Thanks for your suggestions.

Thanks.
poornimayeleswarapu
 
Posts: 8
Joined: Tue Oct 19, 2010 12:46 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Searching

Postby MrSpock » Fri Oct 22, 2010 4:35 pm

s = 'rrrtrtabctyuttt'
fnd = Pos('abc',s)
If fnd <> 0 Then
  Do
    Parse Var s = (fnd) rest
    Say s
    Say fnd
    Say rest
  End


You can find the details on parsing here.
User avatar
MrSpock
Global moderator
 
Posts: 810
Joined: Wed Jun 06, 2007 9:37 pm
Location: Raleigh NC USA
Has thanked: 0 time
Been thanked: 2 times

Re: Searching

Postby poornimayeleswarapu » Fri Oct 22, 2010 4:48 pm

Thank you Spock.. :-)
poornimayeleswarapu
 
Posts: 8
Joined: Tue Oct 19, 2010 12:46 pm
Has thanked: 0 time
Been thanked: 0 time


Return to CLIST & REXX

 


  • Related topics
    Replies
    Views
    Last post