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

Re: regarding regular expression

Thread Previous
February 27, 2009 20:06
Re: regarding regular expression
Message ID:
----- Original Message ----- 
From: "John W. Krahn" <>
To: "Perl Beginners" <>
Sent: Thursday, February 26, 2009 10:54 PM
Subject: Re: regarding regular expression

> 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

or try this

use strict;
use warnings;

my $a = 'pqp-un_1.0G_2009-02-23_17-38-09_5678903.txt';

if ($a =~/_(\d+)\.txt/){
 print "The wanted digits = $1\n";
 print "unmatch\n";

Thread Previous Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About