Nishi wrote:
> Hi:

Hello,

> 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?

$ perl -le'
my @strings = qw(
    Formatting_l_cs.cat
    Formatting_l_da.cat
    Formatting_l_de.cat
    Formatting_l_zh-tw.cat
    );
print /_([^_]+)\./ for @strings;
'
cs
da
de
zh-tw




John
-- 
Perl isn't a toolbox, but a small machine shop where you can special-order
certain sorts of tools at low cost and in short order.       -- Larry Wall

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


Reply via email to