develooper Front page | perl.beginners | Postings from February 2009

Re: regarding regular expression

Thread Previous | Thread Next
From:
John W. Krahn
Date:
February 26, 2009 06:54
Subject:
Re: regarding regular expression
Message ID:
49A6AD24.70708@shaw.ca
Irfan Sayed wrote:
> Hi All,

Hello,

> I have a string like this "pqp-un_1.0G_2009-02-23_17-38-09_5678903.txt
> " now what i need is only all digits before .txt till first underscore.
>  
> which means i need only output as 5678903

$ perl -le'
   $_ = "pqp-un_1.0G_2009-02-23_17-38-09_5678903.txt ";
   print;
   $_ = ( split /\D+/ )[ -1 ];
   print;
'
pqp-un_1.0G_2009-02-23_17-38-09_5678903.txt
5678903


John
-- 
Those people who think they know everything are a great
annoyance to those of us who do.        -- Isaac Asimov

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