thanks a lot. But there is one problem - this is my
fault.  The KEY1, KEY2 don't exactly look like this.  
There are six KEYS. Three are related to KEYS, but the
rest of them are A_BEG A_END, B_OPTIONS, and I need to
extract information between them. I used one variable 
$op=KEY1|KEY2|KEY3|A_BEG|A_END|B_OPTIONS to store all
the alternatives, and tried to use

  my @values = $line =~ /$op.*$op/g; 

  But didn't work as i expected. Are there any
problems. please help me with it. thanks again.


                                         - tao
--- Rob Dixon <[EMAIL PROTECTED]> wrote:
> Tao Wang wrote:
> > Hi Everyone,
> >
> >   I'm having a problem with extracting certain
> strings
> > within a line.  I tried several ways, but not very
> > inefficient.  Can somebody help me with it? thanks
> a
> > lot.
> >
> >   The line might be one of the following:
> >     KEY1 3 4 T KEY2
> >
> >     KEY1 3 4 T KEY2 456 67 KEY3
> >
> >     KEY1 3 4 T KEY2 456 67 KEY3
> >
> >   And I need to extract the information between
> KEYS.
> >
> >   I'm using substr and pos to extract the
> information
> > now, but very complicated.  Are there any better
> ways
> > to do it.  please help me with it. I really
> appreciate
> > it.             - tao
> 
> Hi Tao.
> 
> Does this do what you want? Forgive me for not
> explaining it,
> but it 00:40 here - I'm off to bed!
> 
> HTH,
> 
> Rob
> 
> 
>     use strict;
>     use warnings;
> 
>     while (<DATA>) {
>         chomp;
>         my @values = /KEY\d\s+(.+?)(?=\s+KEY)/g;
>         print join (", ", @values), "\n";
>     }
> 
>     __DATA__
>         KEY1 3 4 T KEY2
>         KEY1 3 4 T KEY2 456 67 KEY3
>         KEY1 3 4 T KEY2 456 67 KEY3
> 
> output:
> 
>     3 4 T
>     3 4 T, 456 67
>     3 4 T, 456 67
> 
> 
> 
> 
> -- 
> To unsubscribe, e-mail:
> [EMAIL PROTECTED]
> For additional commands, e-mail:
> [EMAIL PROTECTED]
> 


__________________________________________________
Do you Yahoo!?
Yahoo! Platinum - Watch CBS' NCAA March Madness, live on your desktop!
http://platinum.yahoo.com

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to