Assignment 1 Answers
-
Find the string 'sound'.
/sound
-
Find the string 'sound' with an upper or lower case S.
/[Ss]ound
-
Find the string 'sound' when it is at the beginning of the line.
/^sound
-
Find the string 'sound' with an upper or lower case S when it is at the beginning of the line.
/^[Ss]ound
-
Find the string 'alive' when it is at the end of the line.
/alive$
-
Find lines that contain 'Buck' and 'Spitz' on the same line in that order.
/Buck.*Spitz
-
Find occurrences of one or two 'z's whether upper or lower case.
/[zZ]\{1,2\} -
Change the string 'Buck' to 'Fido'.
:%s/Buck/Fido/g
-
Add ', the bad dog, ' after each occurrence of 'Spitz'.
:%s/Spitz/Spitz, the bad dog,/g
OR:%s/\(Spitz\)/\1, the bad dog,/g
-
On lines that contain both 'Buck' and 'Spitz', add ', our hero, ' after 'Buck'.
:/Buck.*Spitz/s/Buck/Buck, our hero,/g
OR:/Buck.*Spitz/s/\(Buck\)/\1, our hero,/g