Odd Issue

General questions about using TextPad

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

Post Reply
User avatar
Drxenos
Posts: 210
Joined: Mon Jul 07, 2003 8:38 pm

Odd Issue

Post by Drxenos »

I've noticed an odd issue with the latest TextPad (maybe be in older versions, but I've never noticed it before). I don't know if it's by error or design. If I perform a regular expression on a selected set of lines, and if the line following the selection is empty [i.e., contains just a end-of-line character(s)], the expression will also be performed on that line. If the following lines is NOT empty, the expression will not be performed.

For example: If I use the find expression "^.*$" with the replacement expression "//$&" to comment-out the selected lines for C or C++, it will also comment-out the line following the selection, if and only if, it is blank.

It's not a big deal, but an oddity.


DrX
ben_josephs
Posts: 2456
Joined: Sun Mar 02, 2003 9:22 pm

Post by ben_josephs »

Yes, this is a bug.

Your regex replacement is more complex than necessary. This has the same effect:
Find what: ^
Replace with: //
except that it doesn't suffer from the bug you've reported.
User avatar
Drxenos
Posts: 210
Joined: Mon Jul 07, 2003 8:38 pm

Post by Drxenos »

Thanks. I never knew you could just match anchors.
ben_josephs
Posts: 2456
Joined: Sun Mar 02, 2003 9:22 pm

Post by ben_josephs »

Regexes match strings. An anchor is a regex that matches a zero-length string in some specific context (such as the beginning of a line).
Ryck
Posts: 50
Joined: Thu Mar 17, 2005 4:20 am

Post by Ryck »

ben_josephs wrote:Regexes match strings. An anchor is a regex that matches a zero-length string in some specific context (such as the beginning of a line).
My case is different. I often have to add to the row either by prefixing something or suffixing something to the row. Examples:

^
IM,

or

$
,D

Textpad always processes these commands on the last blank line. I've simply remove the last line but I would prefer it not behave in this way. This is a bug.
Post Reply