A curious behavioral change with ^ and Replace in TP 7.x

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

A curious behavioral change with ^ and Replace in TP 7.x

Post by kengrubb »

I am running TP 7.0.7

If I do this RE Replace, it trims off the last two characters in every line, as I had intended.
Find what: ..$
Replace with:
However, if I do this RE Replace, it trims off the first two characters in every line, and then repeats for that line until the condition is no longer true--either one or zero characters remain on the line.
Find what: ^..
Replace with:
This is not what I intended. I wanted to trim the first two characters from every line, and this RE Replace works, but it seems too pedantic and process intensive. Is there an easier Perlish way for this TP POSIX educated RE nut to accomplish this goal?
Find what: ^..(.*)$
Replace with: $1
(2[Bb]|[^2].|.[^Bb])

That is the question.
ben_josephs
Posts: 2464
Joined: Sun Mar 02, 2003 9:22 pm

Post by ben_josephs »

Confirmed. After removing the first two characters of a line, what were the third and fourth characters are now at the beginning of the line, so the regex matches them. In a certain over-literal sense, TextPad is doing what you asked it to do.

However, this is hardly intuitive, it isn't what TextPad 6 (and some other well-known editors) do, and it isn't what most users would expect it to do.
User avatar
bbadmin
Site Admin
Posts: 1022
Joined: Mon Feb 17, 2003 8:54 pm
Contact:

Post by bbadmin »

We'll fix this in the next release. Thanks for reporting it.
Post Reply