gator456 has asked for the wisdom of the Perl Monks concerning the following question:
with this:Keyword string {
The problem is that the target can be across multiple lines. Example:Keyword 1_string {
Before the input file changed, I had something like this:Keyword string { Keyword string { Keyword string { Keyword string { #string could also be in double quotes Keyword "string" {
I already have a two pass solution. It stores the file in an array and converts the target to a single line. Then it runs the search and replace on the second pass while printing out the line. Very messy. Is there a cleaner way to solve this problemforeach (<>) { s/Keyword\s+\"*([\S"]+)\s+/Keyword 1_$1 /; print; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Help with multiple line regex subsitution
by johngg (Canon) on Apr 14, 2009 at 19:27 UTC | |
by AnomalousMonk (Archbishop) on Apr 14, 2009 at 20:04 UTC | |
by Porculus (Hermit) on Apr 14, 2009 at 22:18 UTC | |
by AnomalousMonk (Archbishop) on Apr 15, 2009 at 16:43 UTC |