in reply to regex: extract multiple number of date patterns from certain lines
#!/usr/bin/perl -w use strict; while (<DATA>) { next if (!/dates processed/); my ($stamp, @dates) = ($_ =~ /(\d+-\d+-\d+)/g); # or my (undef, @dates) = ($_ =~ /(\d+-\d+-\d+)/g); # of course if that is what you want then change # the following line too! print "stamp=$stamp, dates are: @dates","\n"; } #prints...... #stamp=2009-02-19, dates are: 2009-01-31 2009-01-29 2009-01-30 #stamp=2009-02-18, dates are: 2009-02-16 2009-02-17 #stamp=2009-02-19, dates are: 2009-02-18 __DATA__ 2009-02-19 06:03:47,713 SOMETHING WRONG: 2009-01-33, 2009-01-44, 2009- +01-33 2009-02-19 05 58 29 138 dates processed: 2009-01-31, 2009-01-29, 2009- +01-30 2009-02-18 06:03:47,713 dates processed: 2009-02-16, 2009-02-17 2009-02-19 05:58:29,138 dates processed: 2009-02-18
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: regex: extract multiple number of date patterns from certain lines
by Random_Walk (Prior) on Mar 04, 2009 at 19:34 UTC | |
by Marshall (Canon) on Mar 04, 2009 at 22:00 UTC | |
by Random_Walk (Prior) on Mar 05, 2009 at 06:34 UTC | |
by Marshall (Canon) on Mar 06, 2009 at 20:34 UTC |