TC4 Bug: Incorrect "Preview" with PCRE2 + capture group

Tool for Search and Replace across multiple files.
ashy
Posts: 2
Joined: Wed Mar 26, 2025 4:27 pm

TC4 Bug: Incorrect "Preview" with PCRE2 + capture group

Post by ashy »

Build 4.0.0.1 BETA

Steps to reproduce:
1) Create a text file, "test.txt", with the following content:

Code: Select all

The quick brown fox jumped over the 123 lazy dogs.
2) Under Settings > Regular Expression engine:

Code: Select all

Engine: PCRE2
3) Under Find & Replace > Regular Expression:

Code: Select all

Reg Ex: ([0-9]+)
Replace: \1\1
4) Ensure that the Preview window is visible and "Preview replacements" is unchecked (disabled) and that the option, "Generate preview for all matches" is checked (enabled). Click "Replace".

Expected output in the Preview window after clicking "Replace":

Code: Select all

X:\test.txt 
      2   123123 lazy dogs.
Actual output in the Preview window after clicking "Replace":

Code: Select all

X:\test.txt 
      2   123123123123 lazy dogs.
If I open "test.txt", it does show that the file was properly processed (below), it's just that the Preview window is incorrect:

Code: Select all

The quick brown fox jumped over the 123123 lazy dogs.
*I'm not sure what that leading "2" in the gutter is either.
ashy
Posts: 2
Joined: Wed Mar 26, 2025 4:27 pm

Re: TC4 Bug: Incorrect "Preview" with PCRE2 + capture group

Post by ashy »

I just realized this might not be a bug as "Generate preview for all matches" when checked is properly showing 123123123123 as it's reading the change from 123 -> 123123 (and \1\1 from that regex applied to 123123 -> 123123123123).
Last edited by ashy on Wed Mar 26, 2025 5:18 pm, edited 1 time in total.
Post Reply