http://qs1969.pair.com?node_id=251254


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