Uploaded image for project: 'Qt Creator'
  1. Qt Creator
  2. QTCREATORBUG-15175

Regex capture group backreferences do not work when using find and replace in editor

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: P3: Somewhat important P3: Somewhat important
    • Qt Creator 4.7.0-beta1
    • Qt Creator 3.5.0, Qt Creator 4.6.0-beta1
    • Editors
    • None
    • *Found on Windows 7 64-Bit
      *Likely affects all environments

      Qt purportedly follows the Perl conventions for regular expressions. This includes capture groups and backreferences. For instance, let's assume we have the following line of test data:

      foobar

      Now let's assume we perform the following regex search on this line:

      foo(.*)

      The "foobar" line will match this search, and "bar" will be captured as the first group. Now let's assume we wanted to replace this line with a new one using the following expression:

      baz$1

      What we'd expect this to do is replace the "foo" part of "foobar" with "baz" and then append the "bar" first group from our original find expression. After both the find and replace are performed we should end up seeing:

      bazbar

      Instead, we end up seeing:

      baz$1

      This may indicate that regular expressions are either not supported at all for the 'replace' portion of 'find and replace' in the editor, or that backreferences are broken here.

      It is important to note that this is NOT related to programmatic usage of capture groups with regular expressions using the ".matcher" style syntax. This is for the text editor only.

        For Gerrit Dashboard: QTCREATORBUG-15175
        # Subject Branch Project Status CR V

            con Eike Ziller
            nthexwn Alexander Scott Johnson
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes