I had the following regular expression to get the extension from a file 
name:

<code>
$extension = $filename;
$extension =~ s/(^.+\.)([^\.]+)$/$2/;
</code>

But it didn't work (in case the $filename didn't have an extension); so 
I had to add the following line:

<code>
$extension = "" if (!$1);
</code>

What is wrong with my regular expression?
How can it be done in a single regular expression?

-- 
Ahmed Moustafa
http://pobox.com/~amoustafa


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

Reply via email to