Any Suggested Alternatives

General questions about using TextPad

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

Post Reply
User avatar
kengrubb
Posts: 324
Joined: Thu Dec 11, 2003 5:23 pm
Location: Olympia, WA, USA

Any Suggested Alternatives

Post by kengrubb »

I tried doing a RegEx Find of \n{2,}\f

Yielded a "Recursion Too Deep" error.

Can anyone suggestion another way of eliminating additional CR-LF before the FF?

I recorded a brute force Macro doing several Replaces changing \n\n\f to \n\f but I was hoping to do something a little more elegant.

Thanks.
(2[Bb]|[^2].|.[^Bb])

That is the question.
User avatar
s_reynisson
Posts: 939
Joined: Tue May 06, 2003 1:59 pm

Post by s_reynisson »

Well, since no idea has been posted I'll point out the std trick here on these forums for the \n regex problem. The good ol'two step ploy. First replace the \n's with a unique dummy char or string. After that you can regex to your heart's content. When done you replace the remaining dummy chars/strings.
Ex. find \n, replace with @, do your work (ie. find @@\f and replace with @\f), find @, replace with \n. HTH
Then I open up and see
the person fumbling here is me
a different way to be
User avatar
kengrubb
Posts: 324
Joined: Thu Dec 11, 2003 5:23 pm
Location: Olympia, WA, USA

Post by kengrubb »

Starting playing 'round with this. Don't know why it didn't occur to me as I think I did something similar in another Macro. Oh well. Duh moment.

Tried this thinking I'd use hex FF since that isn't likely to show up in a plain text file.

Change \n to \xFF
Change \xFF{2,}\f To \xFF\f
Change \xFF to \n

While I can change \n to \xFF, I cannot change \xFF back to anything. Find appears not to find it. Is this an existing bug in TextPad?
(2[Bb]|[^2].|.[^Bb])

That is the question.
jumpfroggy
Posts: 23
Joined: Fri Jan 14, 2005 9:28 pm

This needs to be fixed in Textpad...

Post by jumpfroggy »

Same problem here... trying to remove multiple blank lines, but keep the single blank lines. Search for \n{2,} replace with \n (so any more than 2 CR's will collapse into 1 blank line).

Textpad gives "Recursion too deep; the stack overflowed." This is a model dialog with some piece of the file as the window title. It keeps popping up, once for every line in the file.

Now I'm in a dilemma; it's a huge file, I can't save the other files I have open, I cannot afford to sit for 10 minutes holding down escape until all the lines have overflowed the stack, one by one. There is no way to cancel, no way to stop the search.

This seems like a bug in textpad. If it is unavoidable that a seemingly simple search will overflow the stack, then it should give the warning and *stop*. Giving the alert for every line in the file is a serious drawback.
User avatar
s_reynisson
Posts: 939
Joined: Tue May 06, 2003 1:59 pm

Post by s_reynisson »

As TP gives an error message for \n+ (invalid regex) it should do the same for \n{x,y} - so yes this must be a bug IMHO.

A possible workaround, first find all non blank lines followed by a blank one and put some dummy string at start of the blank one, use the replace all button:
Find (.+)\n\n
Replace \1\n@\n

Next use the standard TP macro to "Delete Blank Lines".
Finally replace the dummy string with nothing using find @ replace with empty field.

I'm using the dummy string @ here, no good for large files. This workaround fails for the first lines if they are empty as the first regex does not mark one of the lines with @. I have used POSIX regular expression syntax, which can be selected from the Editor page of the Preferences dialog box. HTH
Then I open up and see
the person fumbling here is me
a different way to be
jumpfroggy
Posts: 23
Joined: Fri Jan 14, 2005 9:28 pm

Post by jumpfroggy »

Personally, I just find \n\n and replace with \n, or \n\n\n with \n\n, etc. The big problem is that if you do happen to type in the query mentioned last post, textpad essentially locks up (popping up 1000+ dialog boxes, no chance to save quit cancel, etc). You'll basically lose your work at that point, unless you're very patient.

There are workarounds, the big thing is just making sure textpad doesn't fall into that error loop.
Post Reply