Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: regex to rename last _ with ,

by choroba (Cardinal)
on Sep 11, 2014 at 13:07 UTC ( [id://1100292]=note: print w/replies, xml ) Need Help??


in reply to regex to rename last _ with ,

If you know how to replace the first underscore with a comma, just add reverse:
$file = reverse $file; $file =~ s/_/,/; $file = reverse $file;

To get back what's after the inserted comma, the following should work:

$file =~ s/_([^_]*)/,$1/; my $rest = $1;
لսႽ† ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ

Replies are listed 'Best First'.
Re^2: regex to rename last _ with ,
by ArifS (Beadle) on Sep 11, 2014 at 14:00 UTC
    it was that easy!.... thank you.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1100292]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (4)
As of 2024-04-23 06:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found