Deleting a Number of Specific Lines
Moderators: AmigoJack, bbadmin, helios, Bob Hansen, MudGuard
Deleting a Number of Specific Lines
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.
-
- Posts: 2461
- Joined: Sun Mar 02, 2003 9:22 pm
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):
Edit: Made small change to regex.
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):
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.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]
Edit: Made small change to regex.