* Total Wildcard *

General questions about using TextPad

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

Post Reply
The Doctor

* Total Wildcard *

Post by The Doctor »

Is there one?

I'm sorry if this has been covered, but after a long and frustrating afternoon, I'm not yet ready to browse the forum before putting the question, though I will do afterwards...

In regular expression searches, I know that the dot will search for all characters up to a new line, but not beyond.

As the search/replace function is so much faster than macros for repeated operations, it makes sense to pass matched strings to variables, and paste appropriately with the replacement string. This may need to work in paragraphs (blocks) whose line count is uncertain, so I need a wildcard that will match ANYTHING, including a newline (\n).

I have tried several workrounds to overcome this lack (details at end, for anyone interested), and have not succeeded. In the specific case, I did, but I'd have to find something completely new next time the problem arises, probably.

Please can someone tell me if I am just being foolish, or have really found a problem?

And if there is a simple way out, what is it?

I'm using TextPad v4-40, btw.







Here be details. :)
Workround attempts included using a regexp in a class expression, but that was no good; the first char of the regexp was just used literally.
I also tried nesting regexp's in \( and \), without using that instance of variable assignment in the Replace string. The idea was to try to use \n.* to find a newline and anything that may or may not follow it, all nested in the brackets, and to then treat that bracketing as a single regexp for a following * to find all lines until the next specified term was found. This failed, because the regexp string \(\n.*\) returns an unmatched-bracket error.
I also tried combination of class expressions, and hex byte searches, all to no avail. Even a quick test using \x0D\x0A as a search string failed to find a newline, as it should do.
I tried [[:cntrl:][:print:]] in the hope that as 0D0A (equal to \n) are control characters below value 32, a new line would be matched by the [:cntrl:] and anything else by the [:print:]. It didn't work though.

Basically, as the ONLY way to search for a newline is \n, the task is impossible because if you can't nest regexp's, you also can't use the repetition operator. That would only work on the latest regexp in the pair that is sought, and not the pair, taken as a unit.




A single Total Wildcard, followed by the * (asterisk) repetition operator, would either match till EOF or up to and including some specified term. This small addition would be a welcome one.
evildrome
Posts: 3
Joined: Wed Apr 12, 2006 2:32 pm

Search and Replace using wildcard

Post by evildrome »

Hi All,

I think I need what this guy needs and what every other editor known to mankind has.. a wildcard.

I have text like this:

"*** Transaction Identification ***

....some text I want to get rid of....

*** Text Database Entry ***

.... some text I want to keep

*** Transaction Identification ***

....some text I want to get rid of.... etc"


I want to search and replace

"*** Transaction Identification ***" <*> "***Text Database Entry ***"

with


"***Text Database Entry ***"

where <*> is a wildcard for any character between the two.

Not rocket science... normally.

I bought RegexBuddy but lifes just too short.

BTW I love TextPad which is why I bought it but this is a serious omission.

Cheers,

Wilson Logan.

www.pgoffline.com
ben_josephs
Posts: 2461
Joined: Sun Mar 02, 2003 9:22 pm

Post by ben_josephs »

Good news: TextPad doesn't support wildcards, which are typically used on the command line to refer to groups of filenames; it supports regular expressions, which are very different and far more powerful.

Bad news: in TextPad, dot (.) will not match a newline.

Work-around 1:

Change all newlines to markers not otherwise found in the file, e.g.:
Find what: \n
Replace with: ~#~

[X] Regular expression
Then change the markers in front of *** Text Database Entry *** back to newlines:
Find what: ~#~\*\*\* Text Database Entry \*\*\*
Replace with: \n*** Text Database Entry ***

[X] Regular expression
Then delete everything from *** Transaction Identification *** to and including the end of the line:
Find what: \*\*\* Transaction Identification \*\*\*.*
Replace with: [nothing]

[X] Regular expression
Then change the markers back to newlines.
Find what: ~#~
Replace with: \n

[X] Regular expression
Unfortunately, you may hit problems if the line lengths get too big.

Work-around 2:

Use WildEdit (http://www.textpad.com/products/wildedit/), which uses a far more powerful regular expression recogniser.
evildrome
Posts: 3
Joined: Wed Apr 12, 2006 2:32 pm

Post by evildrome »

Thanks Ben,

Your help is appreciated but why should we all jump through hoops to emulate a feature thats standard on even the most bum basic, free text editor?

I paid for this software & frankly, I feel cheated.

BR,

Wilson.
Post Reply