lngperl has asked for the wisdom of the Perl Monks concerning the following question:
use strict; use warnings; my $str = '6AG3_608_FGG_20100124_20120923418_20126254447_201262512026. +txt'; $str =~ m/(.*)(_\d{11,}?.*)(\.\w+)/; print $1, "\n"; print $2, "\n"; print $3, "\n";
prints
6AG3_608_FGG_20100124_20120923418_20126254447
_201262512026
.txt
But i want it to print
6AG3_608_FGG_20100124
_20120923418_20126254447_201262512026
.txt
Basically the filename gets appened with "_timestamp" after the YYYMMDD part everytime when it gets processed. i want to strip out the time stamps alone.
What i am doing wrong here?
Any help is much appreciated and thanks.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: why my reg ex matches greedy?
by tobyink (Canon) on Jun 25, 2012 at 21:33 UTC | |
|
Re: why my reg ex matches greedy?
by McA (Priest) on Jun 25, 2012 at 20:44 UTC | |
by Anonymous Monk on Jun 25, 2012 at 21:02 UTC | |
by McA (Priest) on Jun 25, 2012 at 21:12 UTC | |
|
Re: why my reg ex matches greedy?
by roboticus (Chancellor) on Jun 25, 2012 at 20:19 UTC | |
by Anonymous Monk on Jun 25, 2012 at 20:56 UTC | |
by roboticus (Chancellor) on Jun 25, 2012 at 22:20 UTC | |
by Anonymous Monk on Jun 26, 2012 at 04:53 UTC | |
by roboticus (Chancellor) on Jun 26, 2012 at 12:14 UTC | |
|