Page 1 of 1

Searching

PostPosted: Fri Oct 22, 2010 3:35 pm
by poornimayeleswarapu
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.

Re: Searching

PostPosted: Fri Oct 22, 2010 3:58 pm
by MrSpock
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.

Re: Searching

PostPosted: Fri Oct 22, 2010 4:17 pm
by poornimayeleswarapu
hi,

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

Thanks.

Re: Searching

PostPosted: Fri Oct 22, 2010 4:22 pm
by poornimayeleswarapu
Hi,

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

Thanks.

Re: Searching

PostPosted: Fri Oct 22, 2010 4:35 pm
by MrSpock
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.

Re: Searching

PostPosted: Fri Oct 22, 2010 4:48 pm
by poornimayeleswarapu
Thank you Spock.. :-)