Page 1 of 1
Deleting a Number of Specific Lines
Posted: Wed Mar 02, 2011 2:30 am
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.
Posted: Wed Mar 02, 2011 10:02 am
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.
Posted: Fri Mar 04, 2011 1:55 am
by afikolami
My files are too long and does not have the same number of lines for this to work. Thanks anyway.