Nishi wrote:
Hi:

I have a strings such as
Formatting_l_cs.cat
Formatting_l_da.cat
Formatting_l_de.cat
Formatting_l_zh-tw.cat
I need to extract the substring before the "." and after the last occurence
of "_" ie in the above cases, it would return "cs" or zh-tw" etc.

How can I achieve this?

HTH,

Rob


use strict;
use warnings;

my @files = qw(
 Formatting_l_cs.cat
 Formatting_l_da.cat
 Formatting_l_de.cat
 Formatting_l_zh-tw.cat);

foreach (@files) {
 my ($country) = /([^_]+)\./i;
 print $country, "\n";
}

**OUTPUT**

cs
da
de
zh-tw

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to