Hallo,
I have a huge file and i want to delete all lines which
do not start with: a href="http://www.
Any idea how to do that?
DELETE EVERYTHING BUT
Moderators: AmigoJack, bbadmin, helios, Bob Hansen, MudGuard
- Bob Hansen
- Posts: 1516
- Joined: Sun Mar 02, 2003 8:15 pm
- Location: Salem, NH
- Contact:
1. Mark all lines that begin with "a href.......
Find: ^a href="http://www\..*
(Regular Expressions, POSIX syntax)
2. Toggle bookmarked lines
Search/Invert all bookmarks
3. Delete bookmarked lines
Edit/Delete/Bookmarked lines
========================================
Edited note, as caught by MudGuard:
The solution provided above will work in TextPad, not in WildEdit.
I did not notice that the question was in the WildEdit forum.
Sorry about that. Thanks MudGuard.
See his WildEdit solution that follows.......
Find: ^a href="http://www\..*
(Regular Expressions, POSIX syntax)
2. Toggle bookmarked lines
Search/Invert all bookmarks
3. Delete bookmarked lines
Edit/Delete/Bookmarked lines
========================================
Edited note, as caught by MudGuard:
The solution provided above will work in TextPad, not in WildEdit.
I did not notice that the question was in the WildEdit forum.
Sorry about that. Thanks MudGuard.
See his WildEdit solution that follows.......
Last edited by Bob Hansen on Sun Jan 28, 2007 10:42 pm, edited 2 times in total.
Hope this was helpful.............good luck,
Bob
Bob
Bob, your solution would be ok if the posting did not appear in the WildEdit board ...
For wildedit:
search for any line:
^.*\n
Ok, replacing this would delete all lines. So we have to exclude the lines matching a certain expression.
For that, we use a negative lookahead assertion at the beginning of the line:
^(?!whatever).*\n
This will find any line not matching "whatever".
Replace these with nothing ==> all lines not starting with "whatever" will be gone.
For wildedit:
search for any line:
^.*\n
Ok, replacing this would delete all lines. So we have to exclude the lines matching a certain expression.
For that, we use a negative lookahead assertion at the beginning of the line:
^(?!whatever).*\n
This will find any line not matching "whatever".
Replace these with nothing ==> all lines not starting with "whatever" will be gone.
- Bob Hansen
- Posts: 1516
- Joined: Sun Mar 02, 2003 8:15 pm
- Location: Salem, NH
- Contact:
-
- Posts: 2461
- Joined: Sun Mar 02, 2003 9:22 pm
-
- Posts: 2461
- Joined: Sun Mar 02, 2003 9:22 pm
It's probably the line endings. Try
^(?!a href).*\r\n
Each line of a text file stored in PC format ends with the two characters: carriage return, line feed (CR LF) (\r\n). WildEdit is somewhat unfriendly in the way it handles carriage returns. If '.' does not match a newline character is selected, then neither . (dot) nor \n matches a carriage return (\r).
^(?!a href).*\r\n
Each line of a text file stored in PC format ends with the two characters: carriage return, line feed (CR LF) (\r\n). WildEdit is somewhat unfriendly in the way it handles carriage returns. If '.' does not match a newline character is selected, then neither . (dot) nor \n matches a carriage return (\r).