latest version (8.1.1, 32 bit, windows 10)
doing a regex search and replace on blank lines , either
^\s*$
or
^$
both lock up the editor, forever spinning cursor. Only choice is to kill Textpad and lose changes.
Anyone else hit this?
Regular expression bug - lock up on blank line search
Moderators: AmigoJack, bbadmin, helios, Bob Hansen, MudGuard
Can't reproduce this in 8.1.1x64 on Win7x64 - since you didn't wrote with what you're replacing your search matches it might indeed match itself endlessly. How about matching/replacing a line including its line end? As in (and replacing it with nothing)
Code: Select all
^\s*$\n
the string you suggested seems to match lines that end with a blank (even if there is other text on the line.
I was looking for either lines that are just carriage returns or maybe with just white space - no other text.
I did confirm one part - if I do "find" on ^$ all is well, finds every line with nothing on it
If I do "replace" with the same search, replacing with nothing - forever spinning wait.
I used to do this in version 7 with no issues.
On a hunch I uninstalled the 32 bit version and installed 64, same result. Very weird, I must be cursed
I was looking for either lines that are just carriage returns or maybe with just white space - no other text.
I did confirm one part - if I do "find" on ^$ all is well, finds every line with nothing on it
If I do "replace" with the same search, replacing with nothing - forever spinning wait.
I used to do this in version 7 with no issues.
On a hunch I uninstalled the 32 bit version and installed 64, same result. Very weird, I must be cursed
CORRECTION: Your string didn't match lines with text, my error reading the highlighting.
I did sort of fix my issue though, by using ^\n to catch beginning and end of line together I avoid the lock up, and remove carriage return only line the way I wanted.
^\s*\n also removes blank lines with white spaces. Probably my mis-use of the $ end of line character
Thank You!
I did sort of fix my issue though, by using ^\n to catch beginning and end of line together I avoid the lock up, and remove carriage return only line the way I wanted.
^\s*\n also removes blank lines with white spaces. Probably my mis-use of the $ end of line character
Thank You!
-
- Posts: 2461
- Joined: Sun Mar 02, 2003 9:22 pm
$ matches the end of a line, but not the newline (the character or characters that terminate the line); that is, it matches the empty string just before the newline.
\n matches a newline.
$\n is exactly equivalent to \n.
The problem with your regex replacement is that having matched a blank line (not including the newline) and replaced it with nothing, the cursor is at the end of the line. But your regex matches the empty string; so it matches again where it is, and replaces what it has matched (the empty string, nothing) with nothing. The cursor is now still at the end of the line, so it matches nothing again and replaces nothing with nothing again. And so ad infinitum.
TextPad might treat this situation in a repetitive replacement as a special case. When the regex has matched and the replacement made, if the regex would, without advancing, match the empty string at its current position, TextPad might advance the cursor, so that it doesn't loop endlessly. Unfortunately, it does not do this, so it does loop endlessly. You might regard this as undesirable behaviour.
The regex with a \n works because it doesn't match the empty string.
This may help to clarify what's going on:
https://forums.textpad.com/viewtopic.php?t=12864
But, there again, it may not!
\n matches a newline.
$\n is exactly equivalent to \n.
The problem with your regex replacement is that having matched a blank line (not including the newline) and replaced it with nothing, the cursor is at the end of the line. But your regex matches the empty string; so it matches again where it is, and replaces what it has matched (the empty string, nothing) with nothing. The cursor is now still at the end of the line, so it matches nothing again and replaces nothing with nothing again. And so ad infinitum.
TextPad might treat this situation in a repetitive replacement as a special case. When the regex has matched and the replacement made, if the regex would, without advancing, match the empty string at its current position, TextPad might advance the cursor, so that it doesn't loop endlessly. Unfortunately, it does not do this, so it does loop endlessly. You might regard this as undesirable behaviour.
The regex with a \n works because it doesn't match the empty string.
This may help to clarify what's going on:
https://forums.textpad.com/viewtopic.php?t=12864
But, there again, it may not!