develooper Front page | perl.beginners | Postings from March 2003

Re: substring problems

Thread Previous | Thread Next
From:
John W. Krahn
Date:
March 18, 2003 17:30
Subject:
Re: substring problems
Message ID:
3E77C810.FE1646C3@acm.org
Tao Wang wrote:
> 
> Hi Everyone,

Hello,

>   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


my @data = split /\s*KEY\d+\s*/, $line;



John
-- 
use Perl;
program
fulfillment

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About