Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

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

by Logicus
on Nov 03, 2011 at 01:57 UTC ( #935545=note: print w/replies, xml ) Need Help??


in reply to Re: Substituting a comma only when it is preceded and followed by a bracket
in thread Substituting a comma only when it is preceded and followed by a bracket

Here's the proper one;

while($_=~ s@\(([^\)]*?),@\($1;@gs){}
  • Comment on Re^2: Substituting a comma only when it is preceded and followed by a bracket
  • Download Code

Replies are listed 'Best First'.
Re^3: Substituting a comma only when it is preceded and followed by a bracket
by Logicus on Nov 03, 2011 at 02:08 UTC
    Oh hang on, ok there was no check to see if the comma was followed by a bracket, so if there was no close bracket, it would replace every comma to the right of the open bracket, which technically would be incorrect because the task specified there to be a following bracket and a single bracket by itself would not count. However as long as the two brackets are there it works fine.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://935545]
help
Chatterbox?
[karlgoethebier]: moans
[karlgoethebier]: ...because of sausage and luncheon meats...
[karlgoethebier]: ... the ultimate coding experience for everyday people...
[karlgoethebier]: ...like me
[marto]: what a mess
[karlgoethebier]: perhaps i need a zerial?

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (10)
As of 2017-12-14 10:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What programming language do you hate the most?




















    Results (389 votes). Check out past polls.

    Notices?