Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-14091

QRegexp and QString: problem with replace using (.*)

    XMLWordPrintable

Details

    • Bug
    • Resolution: Invalid
    • P2: Important
    • 4.8.x
    • 4.6.3
    • None

    Description

      Here are three samples which are not working properly. The same samples but using QRegexp( "(.+)" ) work fine.

      std::cout << QString( "lol" ).replace( QRegExp( "(.*)" ), "\\1 GG" ).toAscii().data() << std::endl; // "lol GG" expected but "lol GG GG" received
      std::cout << QString( "lol lol" ).replace( QRegExp( "(.*)" ), "S" ).toAscii().data() << std::endl; // "S' expected but "SS" received
      std::cout << QString( "lol" ).replace( QRegExp( "(.*)" ), "GG\\1" ).toAscii().data() << std::endl; // "GGlol" expected but "GGlolGG" received
      

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            w00t Robin Burchell
            witekt Witek Tyszkowski
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes