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
\x20but I like to use\x20here 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.
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login