How To DELETE ALL TEXT excluding...

General questions about using TextPad

Moderators: AmigoJack, bbadmin, helios, MudGuard

aimy
Posts: 53
Joined: Mon Nov 01, 2004 4:02 am

How To DELETE ALL TEXT excluding...

Post by aimy »

Let's say I have this:

Code: Select all

TRUNCATE TABLE NIS_DWHv1.ACCESS_POINTS DROP STORAGE
TRUNCATE TABLE NIS_DWHv2.ADDRESSES DROP STORAGE
TRUNCATE TABLE NIS_DWHv3.ADDRESS_SERVICEABILITY DROP STORAGE
TRUNCATE TABLE NIS_DWHv4.AREAS DROP STORAGE
TRUNCATE TABLE NIS_DWHv5.CABLE_CORES DROP STORAGE
TRUNCATE TABLE NIS_DWHv6.CABLE_CORE_ENDS DROP STORAGE
TRUNCATE TABLE NIS_DWHv7.CABLE_DETAIL_INSTANCE DROP STORAGE
TRUNCATE TABLE NIS_DWHv8.CABLE_SHEATHS DROP STORAGE
So, I want TextPad to delete everything else, leaving only the NIS_DWHvn using REGULAR EXPRESSION.

Meaning, based on the above text, I want to use TextPad to make it like this:

Code: Select all

NIS_DWHv1
NIS_DWHv2
NIS_DWHv3
NIS_DWHv4
NIS_DWHv5
NIS_DWHv6
NIS_DWHv7
NIS_DWHv8
So, how am I going to do that??

Thank you.



p/s: INVERT ALL BOOKMARKS won't help
Last edited by aimy on Wed Feb 13, 2008 2:21 am, edited 1 time in total.
ben_josephs
Posts: 2464
Joined: Sun Mar 02, 2003 9:22 pm

Post by ben_josephs »

In TextPad you can't delete all lines not matching an arbitrary regular expression.

Marking all lines containing NIS_DWHv, inverting all bookmarks, and deleting all bookmarked lines might be the easiest way to do it. In what sense will this not help?

But you can do it in WildEdit (http://www.textpad.com/products/wildedit/), which uses a far more powerful regular expression engine than TextPad:
Find what: ^(?!.*NIS_DWHv).*\r?\n
Replace with: [nothing]

[X] Regular expression

Options
[X] '.' does not match a newline character
User avatar
MudGuard
Posts: 1295
Joined: Sun Mar 02, 2003 10:15 pm
Location: Munich, Germany
Contact:

Post by MudGuard »

Replace

Code: Select all

.*(NIS_DWHv[0-9]+).*
by

Code: Select all

\1
ben_josephs
Posts: 2464
Joined: Sun Mar 02, 2003 9:22 pm

Post by ben_josephs »

Ah. Is that what aimy wants? The original message isn't very clear.
User avatar
Bob Hansen
Posts: 1516
Joined: Sun Mar 02, 2003 8:15 pm
Location: Salem, NH
Contact:

Post by Bob Hansen »

I read it the same way as MudGuard did, maybe because it was easier to do. :roll:
Hope this was helpful.............good luck,
Bob
aimy
Posts: 53
Joined: Mon Nov 01, 2004 4:02 am

Post by aimy »

ben_josephs wrote:Ah. Is that what aimy wants? The original message isn't very clear.
Nope! It's not that...

Maybe MudGuard thinks the other way around i.e. to transform NIS_DWHv into
NIS_DWHv1
NIS_DWHv2
NIS_DWHv3
NIS_DWHv4
NIS_DWHv5
NIS_DWHv6
NIS_DWHv7
NIS_DWHv8

I think so.
aimy
Posts: 53
Joined: Mon Nov 01, 2004 4:02 am

Post by aimy »

ben_josephs wrote:In TextPad you can't delete all lines not matching an arbitrary regular expression.

Marking all lines containing NIS_DWHv, inverting all bookmarks, and deleting all bookmarked lines might be the easiest way to do it. In what sense will this not help?

But you can do it in WildEdit (http://www.textpad.com/products/wildedit/), which uses a far more powerful regular expression engine than TextPad:
Find what: ^(?!.*NIS_DWHv).*\r?\n
Replace with: [nothing]

[X] Regular expression

Options
[X] '.' does not match a newline character
I've edited my message.

So are you sure WildEdit can do that??

Anyway, I really hope I can make it with TextPad :cry:
User avatar
Bob Hansen
Posts: 1516
Joined: Sun Mar 02, 2003 8:15 pm
Location: Salem, NH
Contact:

Post by Bob Hansen »

Sorry, I am confused. :?

If YOU think so, that MudGuard's analysis is correct, then why not implement that solution? Why the concern about WildEdit? He has provided a TextPad solution.

This is YOUR question. If YOU think it is correct, then that is the answer. :roll:
Hope this was helpful.............good luck,
Bob
aimy
Posts: 53
Joined: Mon Nov 01, 2004 4:02 am

Post by aimy »

Bob Hansen wrote:Sorry, I am confused. :?

If YOU think so, that MudGuard's analysis is correct, then why not implement that solution? Why the concern about WildEdit? He has provided a TextPad solution.

This is YOUR question. If YOU think it is correct, then that is the answer. :roll:
Sorry Bob, I am confused either..

Coz I've been thinking that MudGuard has got me wrong.

Well anyway, I've tried it but this is the result... :(

Image
aimy
Posts: 53
Joined: Mon Nov 01, 2004 4:02 am

Post by aimy »

To make it more clear,

Instead of using this 2 steps..
1. Replace 'TRUNCATE TABLE ' with nothing
2. Replace '[.][[:print:]]\{1,100\}' with nothing

I want a one single replacement using Regular Expression that will yield this:

Code: Select all

NIS_DWHv1
NIS_DWHv2
NIS_DWHv3
NIS_DWHv4
NIS_DWHv5
NIS_DWHv6
NIS_DWHv7
NIS_DWHv8
out of

Code: Select all

TRUNCATE TABLE NIS_DWHv1.ACCESS_POINTS DROP STORAGE 
TRUNCATE TABLE NIS_DWHv2.ADDRESSES DROP STORAGE 
TRUNCATE TABLE NIS_DWHv3.ADDRESS_SERVICEABILITY DROP STORAGE 
TRUNCATE TABLE NIS_DWHv4.AREAS DROP STORAGE 
TRUNCATE TABLE NIS_DWHv5.CABLE_CORES DROP STORAGE 
TRUNCATE TABLE NIS_DWHv6.CABLE_CORE_ENDS DROP STORAGE 
TRUNCATE TABLE NIS_DWHv7.CABLE_DETAIL_INSTANCE DROP STORAGE 
TRUNCATE TABLE NIS_DWHv8.CABLE_SHEATHS DROP STORAGE

Thank you.
User avatar
MudGuard
Posts: 1295
Joined: Sun Mar 02, 2003 10:15 pm
Location: Munich, Germany
Contact:

Post by MudGuard »

aimy, my solution works.

Maybe you have
Configure - Preferences - Editor - Use POSIX Regular Expression Syntax
switched off? If so, switch it on and try again.
User avatar
Bob Hansen
Posts: 1516
Joined: Sun Mar 02, 2003 8:15 pm
Location: Salem, NH
Contact:

Post by Bob Hansen »

Also make sure there is no trailing space at the end of the Search/Replace RegEx expressions from cut/paste.
Hope this was helpful.............good luck,
Bob
aimy
Posts: 53
Joined: Mon Nov 01, 2004 4:02 am

Post by aimy »

Oh my God, yeah MudGuard, it works like a charm!!! 8) :wink:

Thank you so much!!! Image Image

And I am so sorry for misunderstood you earlier. Please accept my apologize OK.

By the way, may I know why do I have to use POSIX operator instead of using the default one? Is it because I cannot achieve the result if I use the default operator? As far as I know, the difference between the two is only about the syntax, and it seems that POSIX operator is in a less complex form, am I correct?

And also.. Would you mind to explain me a little bit about the coding so that I could understand it better and thus apply the same concept for the future. Let's say I only want to leave all those table names i.e. those text that comes after the dot '.'. How do I achieve that? Please explain that too..

Thank you very much.

I love TextPad very much.. :D
aimy
Posts: 53
Joined: Mon Nov 01, 2004 4:02 am

Post by aimy »

Bob Hansen wrote:Also make sure there is no trailing space at the end of the Search/Replace RegEx expressions from cut/paste.
Thank you Bob. Image

No wonder you seemed to get angry with me yesterday, Image
aimy
Posts: 53
Joined: Mon Nov 01, 2004 4:02 am

Post by aimy »

Yeah, I've got it!!

Replace

Code: Select all

.*[.](\<[[:graph:]]{1,50}\>).*
with

Code: Select all

\1
Yahooo!!!

Any comments from you guys?

By the way, I've also discovered that I can achieve the same result by using the default operator with its complex syntax as you all know.. :(

Can someone please tell me why do we need such a different operator then?? :roll: Why can't make it POSIX alone by default?

Last but not least, will all my macros that used the DEFAULT OPERATOR be affected if I TURN ON the POSIX operator right from now on?

Thank you.
Last edited by aimy on Thu Feb 14, 2008 2:19 am, edited 3 times in total.
Post Reply