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:
and so will this:my $pattern = '(\s*\w+\s+\d{2}\s\d{4}) | (Release\s+\d+\.\d+)'; while(<LOG>) { print $1 if($_ =~ /($pattern)/x ); }
my $pattern = '(\s*\w+\s+\d{2}\s\d{4})|(Release\s+\d+\.\d+)'; while(<LOG>) { print $1 if($_ =~ /($pattern)/ ); }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Regexp for extracting date
by kulls (Hermit) on Dec 20, 2005 at 10:15 UTC |