Results 1 to 12 of 12

Thread: Does QRegExp::lastIndexIn work correct?

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Apr 2011
    Location
    Russia
    Posts
    7
    Qt products
    Qt4

    Default Does QRegExp::lastIndexIn work correct?

    Qt Code:
    1. #include <QCoreApplication>
    2.  
    3. #include <QRegExp>
    4. #include <QDebug>
    5.  
    6. int main(int argc, char *argv[])
    7. {
    8. QCoreApplication a(argc, argv);
    9.  
    10.  
    11. QRegExp reg("(.*)");
    12.  
    13. QString str = "_1234_4567_";
    14.  
    15. int pos1 = reg.indexIn(str, 5);
    16. qDebug() << "F" << pos1 << reg.cap();
    17.  
    18. int pos2 = reg.lastIndexIn(str, 5);
    19. qDebug() << "B" << pos2 << reg.cap();
    20.  
    21. return a.exec();
    22. }
    To copy to clipboard, switch view to plain text mode 

    Generates the following output:

    Qt Code:
    1. F 5 "_4567_"
    2. B 5 "_4567_"
    To copy to clipboard, switch view to plain text mode 

    But I think output of reg.lastIndexIn(str, 5) must be like this:

    Qt Code:
    1. B 0 "_1234_"
    To copy to clipboard, switch view to plain text mode 

    Hm....
    Last edited by Nebelig; 20th June 2011 at 10:52.

Similar Threads

  1. Is this sentence correct?
    By SWEngineer in forum Newbie
    Replies: 6
    Last Post: 21st June 2011, 01:56
  2. Replies: 1
    Last Post: 10th March 2010, 18:19
  3. QRegExp doesn't seem to work as it should
    By thomaspu in forum Qt Programming
    Replies: 3
    Last Post: 21st December 2007, 07:49
  4. how to integrate qt into kdevelop correct way
    By amit_pansuria in forum KDE Forum
    Replies: 1
    Last Post: 25th November 2006, 08:58
  5. QSetting value() not correct
    By bpetty in forum Newbie
    Replies: 1
    Last Post: 14th August 2006, 19:58

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.