Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: Re: Re: How do I replace certain character if condition exists

by kilinrax (Deacon)
on Apr 17, 2003 at 16:58 UTC ( #251254=note: print w/replies, xml ) Need Help??


in reply to Re: Re: How do I replace certain character if condition exists
in thread How do I replace certain character if condition exists

Well, you can do that with a regex, but it's a good degree more complicated.....
abowley@krait:~$ (echo 'Madrid(Spain(Europe)' && echo 'Madrid(Spain(Eu +rope))' && echo 'Madrid(Spain Europe))' && echo 'a(b(c))' && echo 'a +(b (c) d (e) f)') | perl -mstrict -wpe 'BEGIN { $brackets = qr#\([^() +]*(?:(??{$brackets})[^()]*)*\)# }; s#([^)]+?)($brackets)([^(]+)# ( my + $s = $1 ) =~ tr/(/ /; ( my $e = $3 ) =~ tr/)/ /; $s . $2 . $e #ge;' Madrid Spain(Europe) Madrid(Spain(Europe)) Madrid(Spain Europe) a(b(c)) a (b (c) d (e) f)
  • Comment on Re: Re: Re: How do I replace certain character if condition exists
  • Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (4)
As of 2022-01-24 12:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    In 2022, my preferred method to securely store passwords is:












    Results (64 votes). Check out past polls.

    Notices?