Long time user of Textpad, new to expressions, need assistan

General questions about using TextPad

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

Post Reply
nickso
Posts: 1
Joined: Fri Oct 21, 2005 6:12 am

Long time user of Textpad, new to expressions, need assistan

Post by nickso »

I am trying to do the following, have read many posts, some helped, but I can't figure out how to do the following:

The lines below are generated and I remove other "trash" and remove all spaces and all blank lines.
My typical log files are 2,200 to 4,000 lines


I need to delete the entire lines that do not have "done" at the end, but want to leave the lines that don't have "done.

Adding:CDevfhiwpalliX035319Done
Adding:AKhrnX131132
Adding:ATilkarni038163
Adding:RKitmar040752Done
Adding:IMatampalliX013076Done

I have tried ^Adding:.*\n done$ and set the replace option to "match case" so that it would skip the lines with the upper case D in Done.

Also tried ^Adding:*\<done

Would appreciate help with this, I think once I see a working solution I can correlate it with my other needs.

Thanks,
Nick
ben_josephs
Posts: 2461
Joined: Sun Mar 02, 2003 9:22 pm

Post by ben_josephs »

I'm afraid I don't understand exactly what you are trying to do with those regular expressions.

To delete lines that do not match ^Adding:.*Done$, use Search | Find... (<F5>) to bookmark the lines that do match it:
Find what: ^Adding:.*Done$

[X] Regular expression

Mark All
Then invert the bookmarks: Search | Invert All Bookmarks.
Then delete the bookmarked lines: Edit | Delete | Bookmarked Lines.
User avatar
tcebob
Posts: 80
Joined: Fri Mar 28, 2003 1:20 am

Post by tcebob »

Search for
^.*[^done]{4}[ \t]*\n
(Notice the space before the \t.)
Replace with nothing. Be sure the replacement line does not have any spaces.

This will also find "node" "edon" etc. but that doesn't seem to be a problem here. Now if someone steps forward to tell us how to search for not a word he or she will win great honor and thanks.

tcebob
ben_josephs
Posts: 2461
Joined: Sun Mar 02, 2003 9:22 pm

Post by ben_josephs »

A warning to the unwary: [^done] doesn't mean not done. It means: any one character that isn't d, o, n or e. Hence tcebob's {4} to specify that there are four of them.

The regex ^.*[^d][^o][^n][^e]\n matches more lines that don't end in done than ^.*[^done]{4}\n does. (I didn't see a requirement for it to handle trailing white space.) For example, it matches Adding:Qwertyuiop because, although that has an o amongst its last 4 characters, it doesn't have one in the position that done does.

You can't search for the absence of a word using standard regular expressions. But in WildEdit (http://www.textpad.com/products/wildedit/), which uses a far more powerul regular expression recogniser, you can use negative look-ahead, as in (?!done)...., to find four characters that aren't done. (The .... finds any four characters; the (?!done) rejects it if it's done.) (Note that I am not a user of WildEdit. It handles ., \r and \n in a way that I couldn't fathom, and you'll have to fiddle with them at the end of the regex to get it right.)
Post Reply