Description
Given a datafile contains verses from the Bible:
- Each verse begins with the name of the book, a blank, the chapter number,
followed by a colon, the verse number, and the verse itself.
For example, Psm 91:1 indicates that
the chapter number is 91 and the verse number is 1.
- If a line begins with blanks, it is part of the same verse as
the previous line.
If a verse is from the same book and the same chapter as the previous one,
we want to replace everything up to and including the colon with blanks
of the same length.
|
| Raw Input
| Psm 91:1 He who dwells in the shelter of the Most High
will rest in the shadow of the Almighty.
Psm 91:2 I will say of the LORD, "He is my refuge and my fortress,
my God, in whom I trust."
Psm 127:3 Sons are a heritage from the LORD,
children a reward from him.
Psm 127:4 Like arrows in the hands of a warrior are sons born in one's youth.
Psm 9:1 I will praise you, O LORD, with all my heart;
I will tell of all your wonders.
Psm 9:2 I will be glad and rejoice in you;
I will sing praise to your name, O Most High.
Psm 9:3 My enemies turn back; they stumble and perish before you.
|
|
| Desired Output
| Psm 91:1 He who dwells in the shelter of the Most High
will rest in the shadow of the Almighty.
2 I will say of the LORD, "He is my refuge and my fortress,
my God, in whom I trust."
Psm 127:3 Sons are a heritage from the LORD,
children a reward from him.
4 Like arrows in the hands of a warrior are sons born in one's youth.
Psm 9:1 I will praise you, O LORD, with all my heart;
I will tell of all your wonders.
2 I will be glad and rejoice in you;
I will sing praise to your name, O Most High.
3 My enemies turn back; they stumble and perish before you.
|
|
Script and Comments
Script1 [ 1] /^ +/b
[ 2] G
[ 3] s/^([^:]+:)([^\n]*)\n\1\n(.*)/\3\2/
[ 4] t
[ 5] s/\n.*//p
[ 6] s/:.*$/:/
[ 7] h
[ 8] s/./ /g
[ 9] H
[10] d
| |
|