Deleting a Number of Specific Lines

General questions about using WildEdit

Moderators: AmigoJack, helios, bbadmin, Bob Hansen, MudGuard

Post Reply
afikolami
Posts: 3
Joined: Wed Mar 02, 2011 2:22 am

Deleting a Number of Specific Lines

Post by afikolami »

How do I delete a number of specific lines in WildEdit? For example: I want to delete the 1st, 2nd, 10th, and 20th lines in all the files in my folder. Thanks.
ben_josephs
Posts: 2456
Joined: Sun Mar 02, 2003 9:22 pm

Post by ben_josephs »

WildEdit does not handle the beginning-of-text anchor (\A or \`) correctly: it matches at the beginning of every line instead of only at the beginning of the first line. So you can't count lines from the beginning of the file. This is a bug.

However, if your text has fewer than 40 lines, a regex matching 20 lines will only be able to match once, and will do so as early as possible, that is, at the beginning of the file. In this case you can use something like this (assuming your files have CR,LF line endings):
Search for: ^(?:.*\r\n){2}((?:.*\r\n){7}).*\r\n((?:.*\r\n){9}).*\r\n

[X] Regular expression
[ ] "." matches end of line characters [i.e., not selected]

Replace with: $1$2

[ ] Literal replacement [i.e., not selected]
If your files are too long for this to work, but they all have the same number of lines, you can count from the end of the file using the end-of-text anchor (\z or \'), which WildEdit does handle correctly.

Edit: Made small change to regex.
afikolami
Posts: 3
Joined: Wed Mar 02, 2011 2:22 am

Post by afikolami »

My files are too long and does not have the same number of lines for this to work. Thanks anyway.
Post Reply