Delete lines that end with a specific string?
Moderators: AmigoJack, bbadmin, helios, Bob Hansen, MudGuard
Delete lines that end with a specific string?
Can I use Regex to delete all lines in a text file that end with a specific string, in this case -a---(plus the EOL character)?
That's 'minus,a,minus,minus,minus,EOL'
That's 'minus,a,minus,minus,minus,EOL'
-
- Posts: 2461
- Joined: Sun Mar 02, 2003 9:22 pm
-
- Posts: 2461
- Joined: Sun Mar 02, 2003 9:22 pm
In fact, I often do this sort of thing in two steps:
1. Mark all the lines to be deleted:
Search | Find... (<F5>):
Edit | Delete | Bookmarked Lines
This gives me a better chance of avoiding doing something stupid (and the regex is slightly simpler).
1. Mark all the lines to be deleted:
Search | Find... (<F5>):
2. Delete the marked lines:Find what: -a---$
[X] Regular expression
Mark All
Edit | Delete | Bookmarked Lines
This gives me a better chance of avoiding doing something stupid (and the regex is slightly simpler).
-
- Posts: 2461
- Joined: Sun Mar 02, 2003 9:22 pm
-
- Posts: 2461
- Joined: Sun Mar 02, 2003 9:22 pm
Only in POSIX and Unix environments. However, TextPad usually lives in... well... none of both.ben_josephs wrote:the omission of a newline at the end of a text file is usually an error
No, I've learnt otherwise. Always implying a newline at the end is an important detail/requirement and is different from dealing with reality. Just because it should be like that does by far not mean it is done like that by everyone. And Windows is a whole different environment on top of that.
Re: Delete lines that end with a specific string?
Thank you gentlemen! You've added precious time back to my days!