Results 1 to 4 of 4

Thread: QRegExp lastIndexOf always minimal?

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,376
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Thanks
    4
    Thanked 5,019 Times in 4,795 Posts
    Wiki edits
    10

    Default Re: QRegExp lastIndexOf always minimal?

    Hmm... this indeed is strange but I can believe the behaviour is intentional.

    You may obtain the result you want using this code:
    Qt Code:
    1. #include <QString>
    2. #include <QRegExp>
    3.  
    4. int main(int argc, char **argv){
    5. QString string = "coolfilename02.153.ext";
    6. QRegExp rx("([0-9]+)(\\.[^\\.]*)$");
    7. rx.setMinimal(true);
    8. rx.indexIn(string);
    9. qDebug(qPrintable(QString("0: %1 1: %2 2: %3").arg(rx.cap(0)).arg(rx.cap(1)).arg(rx.cap(2))));
    10. return 0;
    11. }
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Nov 2006
    Posts
    20
    Qt products
    Qt4
    Platforms
    Unix/X11
    Thanks
    1

    Default Re: QRegExp lastIndexOf always minimal?

    Thanks Guys - seems I've got a whole bunch of solutions now :-)

    It also hit me last night while trying to fall asleep (why does code not working do that to me?)

    [^0-9][0-9]+\.

    Thanks again,

    Alan.

Similar Threads

  1. QRegExp progblem
    By high_flyer in forum Qt Programming
    Replies: 1
    Last Post: 6th September 2006, 12:12
  2. QRegExp?
    By Marco812 in forum Qt Programming
    Replies: 3
    Last Post: 4th August 2006, 08:31
  3. need help for my QRegExp
    By patcito in forum Qt Programming
    Replies: 1
    Last Post: 27th May 2006, 16:29
  4. Trouble parsing using simple QRegExp
    By johnny_sparx in forum Qt Programming
    Replies: 4
    Last Post: 24th February 2006, 00:42

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
  •  
Qt is a trademark of The Qt Company.