Find exact lines
-
I am looking for a way to replace EXACT lines. I have a file that has "Word " (with space, without quotes) at the beginning of each line. What I am wanting to do is replace every line that contains "Word " with nothing after it. For example:
Word
Word this is the next line
Word another line
Wordbecomes
Word,
Word this is the next line
Word another line
Word, -
Not too hard, try this:
Find-what zone:
Word\x20$
Replace-with zone:Word,
Search-mode: Regular-expressionYou can use a plain old space instead of the
\x20
but I like to use\x20
here on this site because it is more visible. Either works when you are actually doing it.So in the spirit of learning something, the
$
is the key element here. It basically means end-of-line…so you are searching for W…o…r…d…space…followed by nothing else on the line. Replacement affects only those cases where a search match occurred, obviously.