PRA007 has asked for the wisdom of the Perl Monks concerning the following question:
I am using strawberry perl for windows.
I have following rtf text for example for performing regex find and replace
1
2
3
4
dog
1
2
3
4
5
puppy
7
8
I am using following regex in notepad++ for testing which works. I don't know how to use the same in perl. I have tried all the way but could not make it happen. below is one of my one liner.
perl -i.bak -pe "BEGIN{undef $/;} s/(dog)(.*[\r\n]+){6}(.*)/$&$1=$3/smg" 4.txt8
Here I want to identify dog = puppy. How to identify string that are fixed lines apart and do the replacements?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Regex find and replace involving new line
by Corion (Patriarch) on Dec 14, 2015 at 09:57 UTC | |
|
Re: Regex find and replace involving new line
by choroba (Cardinal) on Dec 14, 2015 at 10:16 UTC | |
by PRA007 (Initiate) on Dec 14, 2015 at 10:23 UTC | |
by Corion (Patriarch) on Dec 14, 2015 at 10:24 UTC | |
by PRA007 (Initiate) on Dec 14, 2015 at 11:12 UTC | |
by Corion (Patriarch) on Dec 14, 2015 at 11:54 UTC | |
| |
|
Re: Regex find and replace involving new line
by Anonymous Monk on Dec 14, 2015 at 12:42 UTC |