Description
In the example, we want to keep the first three occurrences of word
intact, and replace every other one with six dashes.
|
| Raw Input
|
| Desired Output
| word_1
much more data...
word_2 word_3 word_4
much more data...
word_5 word_6
word_7
much more data...
word_8 final word_9
|
| word_1
much more data...
word_2 word_3 ------_4
much more data...
------_5 ------_6
------_7
much more data...
------_8 final ------_9
|
|
Script and Comments
Script1 [ 1] :0
[ 2] /(word.*){3}/!{
[ 3] $!N
[ 4] $!b 0
[ 5] }
[ 6] :1
[ 7] /(word.*){4}/{
[ 8] s/^(.*)word/\1------/
[ 9] t 1
[10] }
[11] :2
[12] n
[13] s/word/------/g
[14] b 2
| |