Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
Hi Monks, I want to do a nested replace. But I do not know how to code it.
I want to delete from string(= complete file with multiple lines) everything between "/*" and */, but all "\n" should be untouched.
My Idea was to search for "/*..*/ and than replace in a second step all characters not equal to \n with ""
Here my construct, which does not work :-(Can you tell me what I how to code it? By the way: Is there a shorter expression for : [\0-\255]? Thanks !!s:/\*([\0-\255]*?)\*/:($1=~s/[^\n]//g):g; ^^^^^^^^^^^^^^^^ nested replace is seen as text +and not executed
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: nested replace
by choroba (Cardinal) on Mar 18, 2016 at 08:56 UTC | |
by Anonymous Monk on Mar 18, 2016 at 09:47 UTC | |
by choroba (Cardinal) on Mar 18, 2016 at 10:09 UTC | |
by Anonymous Monk on Mar 18, 2016 at 10:07 UTC | |
by Anonymous Monk on Mar 18, 2016 at 10:13 UTC | |
|
Re: nested replace
by AnomalousMonk (Archbishop) on Mar 18, 2016 at 13:22 UTC | |
|
Re: nested replace
by Anonymous Monk on Mar 18, 2016 at 09:28 UTC | |
|
Re: nested replace
by Discipulus (Canon) on Mar 18, 2016 at 08:57 UTC | |
|
Re: nested replace
by Anonymous Monk on Mar 18, 2016 at 08:55 UTC |