Page 1 of 1

7.1 broke regex

Posted: Tue Dec 24, 2013 10:04 pm
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.

Posted: Thu Dec 26, 2013 11:43 am
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.

Posted: Thu Dec 26, 2013 5:04 pm
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.

Posted: Mon Dec 30, 2013 8:25 am
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?