Description
We want to replace each of the last 3 matches of word with
six dashes.
|
| Raw Input
|
| Desired Output
| word_1 word_2 word_3
much more data...
word_4 word_5
much more data...
word_6 word_7
word_8
much more data...
word_9 final word_10
|
| word_1 word_2 word_3
much more data...
word_4 word_5
much more data...
word_6 word_7
------_8
much more data...
------_9 final ------_10
|
|
Script and Comments
Script1 [ 1] /word/!b
[ 2] :0
[ 3] $!{
[ 4] N
[ 5] /(.*word){3}/!b 0
[ 6] }
[ 7] :1
[ 8] /\n(.*word){3}/{
[ 9] P
[10] s/^[^\n]*\n//
[11] }
[12] $!{
[13] N
[14] b 1
[15] }
[16] :2
[17] s/^(.*)word/\1------/
[18] x
[19] s/^/\n/
[20] /^\n{3}$/!{
[21] x
[22] /word/b 2
[23] }
[24] x
| |