Hi

$file1='doctobepublish.new.pdf';
if ($file1 =~ /\.[^\.]*\./)
{
 print "Multiple Dots!";
}
else
{
 print "Single Dot!";
}

-aman.

-----Original Message-----
From: Marco Centemeri [mailto:[EMAIL PROTECTED]]
Sent: Monday, December 16, 2002 12:41 PM
To: Perl Beginners Mailing List
Subject: again a regex help needed


Hello All,
I'd like to know if a file name is like namefile.ext (only one dot in the
name)
or namefile.xxx.zzzzz.ext (more than one dot in the name).
I tried with regex:

$file1='doctobepublish.new.pdf';

if ( $file1 =~ /\.{2,}/ ) { print "KO filename not properly formatted"; }
else                      { print "OK filename is good"; }

This doesn't work and the match is true only if the two dots are
consecutive.

doctobepublish.new.pdf =~ /\.{2,}/          doesn't match
doctobepublish..new.pdf =~ /\.{2,}/                 match

My idea, probably wrong, is that regex process scan all the string and try
to match all the possible so 

doctobepublish.new.pdf =~ /\.{2,}/        should match
anotherdoctobepublish.pdf =~ /\.{2,}/     should not match


May anybody help me to solve the problem and to understand better how regex
works?
I've already read perlquik and perlre but some points are still foggy!


Thanks a lot
               Marco Centemeri


-- 
************************************************************
Eng. MARCO CENTEMERI

 Telecommunication and Peripherals/Automotive Groups
 Audio & Automotive Division
 Automotive Business Unit
 Bosch Product Engineer

STMicroelectronics Srl                 Tel: +39.039.603.5784
20041 Agrate Brianza - Italy           Fax: +39.039.603.6343
Via C. Olivetti, 2                  Mobile: +39.0348.8861577
Building F11                          [EMAIL PROTECTED]
************************************************************

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to