Here is a shot: # # Loading header with the data provided # my $header = <<'HEADER'; To: "Ankit Gupta" <[EMAIL PROTECTED]> References: <[EMAIL PROTECTED]> <001c01c200e0$9a1d9720$7d82c8cb@ashokgup> <[EMAIL PROTECTED]> Subject: Re: Date: Thu, 23 May 2002 19:47:50 +0530 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 5.00.2615.200 X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2615.200 Return-Path: [EMAIL PROTECTED] HEADER
printf "header:\n%-s\n", $header; # print header data out if ( $header !~ /Date:\s(.+)$/m ) { # using ! for not found and need the m for multiple line printf "Expecting a Date line with format of Date: xxx nnn .....\n"; printf "Did not get a hit. Data being used:\n"; printf "%-s\n"; die "Bad data"; } my $MyDateInfo = $1; # capture the date printf "Date: <%-s>\n", $MyDateInfo; # print the date out Output: Date: <Thu, 23 May 2002 19:47:50 +0530> <- where the data between <> is the date captured. Wags ;) -----Original Message----- From: Ankit Gupta [mailto:[EMAIL PROTECTED]] Sent: Friday, May 24, 2002 08:14 To: [EMAIL PROTECTED] Subject: Need help in Regular Expression Hello, I am working on a project in which I need to get Date part of below written header. I am trying to use Regular expression to extract Date: line. I am able to achieve everything after the Date: word but not only that line. I mean to say that I need only this string Thu, 23 May 2002 19:47:50 +0530 . Can someone help me in this. I am trying $header =~ m/Date:/; and then my $ab = " $' \n"; but this gives me everything after Date: word. As I wrote above, I need only Thu, 23 May 2002 19:47:50 +0530 string To: "Ankit Gupta" <[EMAIL PROTECTED]> References: <[EMAIL PROTECTED]> <001c01c200e0$9a1d9720$7d82c8cb@ashokgup> <[EMAIL PROTECTED]> Subject: Re: Date: Thu, 23 May 2002 19:47:50 +0530 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 5.00.2615.200 X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2615.200 Return-Path: [EMAIL PROTECTED] Regards, Ankit -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]