Page 1 of 2
How To DELETE ALL TEXT excluding...
Posted: Tue Feb 12, 2008 1:26 am
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
Posted: Tue Feb 12, 2008 9:43 am
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
Posted: Tue Feb 12, 2008 11:40 am
by MudGuard
Posted: Tue Feb 12, 2008 11:50 am
by ben_josephs
Ah. Is that what aimy wants? The original message isn't very clear.
Posted: Wed Feb 13, 2008 1:05 am
by Bob Hansen
I read it the same way as MudGuard did, maybe because it was easier to do.

Posted: Wed Feb 13, 2008 2:25 am
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.
Posted: Wed Feb 13, 2008 2:30 am
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

Posted: Wed Feb 13, 2008 4:40 am
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.

Posted: Wed Feb 13, 2008 8:40 am
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.

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...

Posted: Wed Feb 13, 2008 8:51 am
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.
Posted: Wed Feb 13, 2008 11:12 am
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.
Posted: Wed Feb 13, 2008 11:43 pm
by Bob Hansen
Also make sure there is no trailing space at the end of the Search/Replace RegEx expressions from cut/paste.
Posted: Thu Feb 14, 2008 12:56 am
by aimy
Oh my God, yeah MudGuard, it works like a charm!!! 8)
Thank you so much!!!
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..

Posted: Thu Feb 14, 2008 12:58 am
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.
No wonder you seemed to get angry with me yesterday,

Posted: Thu Feb 14, 2008 1:15 am
by aimy
Yeah, I've got it!!
Replace
with
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??

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.