DELETE EVERYTHING BUT

General questions about using WildEdit

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

Post Reply
martib
Posts: 19
Joined: Wed Aug 23, 2006 2:28 pm

DELETE EVERYTHING BUT

Post by martib »

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?
User avatar
Bob Hansen
Posts: 1516
Joined: Sun Mar 02, 2003 8:15 pm
Location: Salem, NH
Contact:

Post by Bob Hansen »

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.......
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
User avatar
MudGuard
Posts: 1295
Joined: Sun Mar 02, 2003 10:15 pm
Location: Munich, Germany
Contact:

Post by MudGuard »

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.
User avatar
Bob Hansen
Posts: 1516
Joined: Sun Mar 02, 2003 8:15 pm
Location: Salem, NH
Contact:

Post by Bob Hansen »

Aaargh!

Thanks MudGuard. I have done this more than once. :oops:

Thanks for catching that, I will modify the posting to mention that.
Hope this was helpful.............good luck,
Bob
ben_josephs
Posts: 2461
Joined: Sun Mar 02, 2003 9:22 pm

Post by ben_josephs »

MudGuard wrote:^(?!whatever).*\n
Make sure that
[X] Regular expression
and
Options
[X] '.' does not match a newline character
are selected.
martib
Posts: 19
Joined: Wed Aug 23, 2006 2:28 pm

Post by martib »

thanks for all the help,

but even with the correct options nothing was deleted.

^(?!a href).*\n
^(?!a ).*\n
^(?!href).*\n

none of them worked
ben_josephs
Posts: 2461
Joined: Sun Mar 02, 2003 9:22 pm

Post by ben_josephs »

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).
Post Reply