Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: Substituting a comma only when it is preceded and followed by a bracket

by JavaFan (Canon)
on Nov 02, 2011 at 22:52 UTC ( [id://935516]=note: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    my $str = do {my $i; join "", map {$_ eq '(' ? $i++ : $_ eq ')' && $i 
    +? $i-- : $_ eq ',' && $i ? ($_ = ';') : 0; $_} split '[(,)]', $str};
    
  2. or download this
        "(foo),(bar)"
    
  3. or download this
    substr($str, index($str, "("), rindex($str, ")") - length($str)) =~ s/
    +,/;/g;
    

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (4)
As of 2024-04-19 06:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found