7.1 broke regex

General questions about using TextPad

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

Post Reply
vr8ce
Posts: 25
Joined: Thu Dec 04, 2003 6:54 pm

7.1 broke regex

Post by vr8ce »

7.1.0 on Win7 Ultimate

7.1 appears to have broken regular expressions. Simplest text case: put several new lines in a new file, then replace "^" with "(". It will say "xx replaced", where xx is the number of blank lines, but there's nothing there. IOW, no parentheses were added.

I originally found the problem while trying to add a closing parenthesis at the end of a line, so the above isn't the only thing that's broken, just a sample.

I downgraded to 7.09 (after having to Google to find it) and it works fine.
User avatar
bbadmin
Site Admin
Posts: 878
Joined: Mon Feb 17, 2003 8:54 pm
Contact:

Post by bbadmin »

From the documentation for Replacement Format Strings in the online help:
The characters '(' and ')' perform lexical grouping, so use \( and \) if you want a to output literal parenthesis.
In the case you described, TextPad is inserting an empty lexical group, but it would be better if it flagged the unmatched parenthesis, as it does for regular expressions.
User avatar
jeffy
Posts: 323
Joined: Mon Mar 03, 2003 9:04 am
Location: Philadelphia

Post by jeffy »

It was "broken" before (not really broken, per se, it just didn't conform to the documentation). Now it "works".

Even
-Find what: xxx
-Replace with: ))))))))))))))))))))))))))))))))))))
-Regex CHECKED

now replaces the X-s with NOTHING, where before 7.1 it replaced it with those literal parens.

An additional issue I had upgrading to 7.1 was that for many months I was successfully using

Code: Select all

^[\t ]*(?=[\S])
to unindent the selected text. Now in 7.1 it doesn't work. As advised by TextPad support, here is a much simpler and elegant regex that does the same thing:

Code: Select all

^\h+
I changed it, and it works in 7.1 again.
vr8ce
Posts: 25
Joined: Thu Dec 04, 2003 6:54 pm

Post by vr8ce »

jeffy wrote:It was "broken" before (not really broken, per se, it just didn't conform to the documentation). Now it "works".
If by "before" you mean the entire history of TextPad. I've been using it since 4.x, i.e. for 13+ years, and it's worked this way at least that long. After that much time, the behavior is de facto correct, and it's the documentation that's wrong.

Further, other than the phrase appearing in the help, there's no indication of what "lexical grouping" even means in a replacement expression (I obviously understand why the parentheses have to be quoted in the search expression).

Why, after all this time, did this suddenly change?
Post Reply