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

QString::contains ( QRegExp & rx ) doesn't capture regexp

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • Not Evaluated
    • 5.0.0
    • 4.7.4
    • None
    • kubuntu 11.10 gcc-4.6.1 (Ubuntu/Linaro 4.6.1-9ubuntu3)
    • I9c239ff790a139c7820ef1aeced89d31320ae6b0

    Description

      http://doc.qt.nokia.com/4.7/qstring.html#contains-6
      bool QString::contains ( QRegExp & rx ) const

      If there is a match, the rx regular expression will contain the matched captures (see QRegExp::matchedLength, QRegExp::cap).

      int QRegExp::matchedLength () const

      Returns the length of the last matched string, or -1 if there was no match.

      RX.cpp
      QString string("abcd");
      QRegExp rx("[bc]");
      qDebug() << string.contains(rx) << rx.cap(0) << rx.matchedLength();
       
      /**
      true "" 
      Программа неожиданно завершилась. // (CRASH)
      */
      

      "contains()" return true, so I thought "cap()" should return captured text, but...
      and I got crash when I try to invoke "matchedLength()"

      Tnx.

      Attachments

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

        Activity

          People

            w00t Robin Burchell
            sahab Alex Diev
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes