in reply to Regexp for extracting date

You need to either use the "x" modifier for your match (so that it ignores whitespace in the pattern) or remove the space between your first pattern and the |. Also, you're requiring whitespace before the date, but there is none in your data. This will work:

my $pattern = '(\s*\w+\s+\d{2}\s\d{4}) | (Release\s+\d+\.\d+)'; while(<LOG>) { print $1 if($_ =~ /($pattern)/x ); }
and so will this:
my $pattern = '(\s*\w+\s+\d{2}\s\d{4})|(Release\s+\d+\.\d+)'; while(<LOG>) { print $1 if($_ =~ /($pattern)/ ); }

Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it. -- Brian W. Kernighan

Replies are listed 'Best First'.
Re^2: Regexp for extracting date
by kulls (Hermit) on Dec 20, 2005 at 10:15 UTC
    hi,
    Thanx a lot.your 'x' modifier works fine.

    -kulls