Page 1 of 1
Any Suggested Alternatives
Posted: Thu Jul 01, 2004 6:02 pm
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.
Posted: Sat Jul 03, 2004 11:11 pm
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
Posted: Fri Jul 09, 2004 4:42 pm
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?
This needs to be fixed in Textpad...
Posted: Thu Jan 20, 2005 1:59 am
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.
Posted: Thu Jan 20, 2005 2:44 am
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
Posted: Thu Jan 20, 2005 5:32 am
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.