|
In a message dated 2/16/2006 8:38:41 A.M. Eastern Standard Time,
[EMAIL PROTECTED] writes:
> a simple regular _expression_ is needed to eliminate the file extension:
> > $_="123"; > /(XX)YY/; > print "$1\n" ; # result: "123"; > > $_="123.txt"; > /(XX)YY/; > print "$1\n" ; # result: "123" > > $_="123.txt.txt"; > /(XX)YY/; > print "$1\n" ; # result: "123.txt"; > > Any suggestions for /(XX)YY/ ? Thanks. how about
$_ =~ /^ (.*?) (?: \. [^.]* )? $/x;
print $1;
although if you really want to eliminate (rather than exclude) the
extension, try
$filename =~ s/ \. [^.]* $//x;
print $filename;
also - consider case of ``123.'' (dot at very end of string).
hth -- bill walters
|
_______________________________________________ ActivePerl mailing list [email protected] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
