in reply to Re: Regex To Remove File Extension
in thread Regex To Remove File Extension
You're assuming too much, your regex will fail on:
and you'll get a bad result with *nix dotfilesindex.html foo.pl CGI.pm video.mpeg foo.pl~
.foo .bar
Focus on the requirements - 1) A file must contain an extension 2) the extension is everything following the final dot
my @names = qw/ index.html foo.pl CGI.pm video.mpeg foo.pl~ .bash_hist +ory .bash_rc /; foreach my $string ( @names ) { print "$string -> "; $string =~ s/(.+)\.[^.]+$/$1/; print "$string\n"; }
grep
One dead unjugged rabbit fish later...
One dead unjugged rabbit fish later...
In Section
Seekers of Perl Wisdom