in reply to Pattern replace in a file name
A pattern like [.0-9]+ will detect a sequence of digits and dots, also including something like 0.000.0, probably undesirably so. For your examples it would work, full code could be like this:
use strict; use warnings; my @f = qw( /fd/gfree/tere/frf4545/geerg/fds/0.1/fsdf/dsakdsa/ /fd/gfree/tere/frf4545/geerg/dfds/5.9/fdsf/fdsfd/ /fd/gfree/tere/frf4545/geerg/dsad/02.44/fdsf/fdsf/ ); s|(/[.0-9]+)/.*|$1| for @f; print "$_\n" for @f;
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Pattern replace in a file name
by kaushik9918 (Sexton) on Mar 28, 2019 at 09:33 UTC | |
by hippo (Bishop) on Mar 28, 2019 at 09:47 UTC | |
by kaushik9918 (Sexton) on Mar 28, 2019 at 09:52 UTC | |
by hdb (Monsignor) on Mar 28, 2019 at 09:41 UTC |
In Section
Seekers of Perl Wisdom