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

QStringList.indexOf() with "^" doesn't work

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P3: Somewhat important
    • None
    • 4.8.2
    • None
    • Windows 7 64bit Japanese Edition
      Qt 4.8.2
      QtCreator 2.5.2

    Description

      When I tried to know the index of the QString in QStringList,
      "^" doesn't work well.
      I expected that the pattern "^TEST" works.
      I checked it with QString, too. It works.

      Following code can duplicate the situation.

          {
              QStringList	testList;
              QRegExp		testReg;
              int		rslt;
      
              testList << "abc" <<  "REG_EXP_TEST" << "TEST_STRING";
      
              // search the index of QString which starts with "TEST"
              testReg.setPattern("^TEST");
              rslt = testList.indexOf(testReg);
              // rslt == -1. Can not find
      
              testReg.setPattern("^TEST*");
              rslt = testList.indexOf(testReg);
              // rslt == -1. Can not find
      
              testReg.setPattern("^TEST.*");
              rslt = testList.indexOf(testReg);
              // rslt == 2. Works.
      
          }
      
          {
              QString		testString;
              QRegExp		testReg;
              int		rslt;
      
              testString = tr("TEST_STRING");
              testReg.setPattern("^TEST");
              rslt = testString.indexOf(testReg);
              // rslt == 0. Works
          }
      

      Attachments

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

        Activity

          People

            cnn Qt Core & Network
            t_katoh Takenori KATO
            Votes:
            3 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes