Results 1 to 8 of 8

Thread: Is it possible to use QString::contains(QRegExp) in a switch statement?

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #6
    Join Date
    Nov 2010
    Posts
    315
    Thanked 53 Times in 51 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Is it possible to use QString::contains(QRegExp) in a switch statement?

    Can you be more specific what you are parsing?
    I'm quite sure that this issue can be solved in better way.
    One of possibilities is union of regular expretions:
    Qt Code:
    1. QRegExp regExp("(regExp1)|(regExp2)|(regExp3)|(regExp4)")
    2.  
    3. while(1) // this (!in.EOF) was wrong!
    4. {
    5. line = in.readLine();
    6. if (line.isNull()) {
    7. break;
    8. }
    9. if(line.contains(regExp)){
    10. const QStringList result = regExp.capturedTexts();
    11. int i;
    12. for (i=0; i<result.count(); ++i) {
    13. if (!result[i].isEmpty()) {
    14. break; // or some action to take
    15. }
    16. }
    17. // process i value
    18. }
    19. }
    To copy to clipboard, switch view to plain text mode 
    Last edited by MarekR22; 3rd March 2011 at 10:41.

Similar Threads

  1. Search for QRegExp in a QString
    By Abc in forum Qt Programming
    Replies: 6
    Last Post: 13th August 2008, 09:31
  2. confusion with a STATEMENT used frequently
    By salmanmanekia in forum Newbie
    Replies: 3
    Last Post: 11th June 2008, 20:54
  3. QString manipulation - QRegExp
    By mattia in forum Newbie
    Replies: 1
    Last Post: 18th March 2008, 11:21
  4. QString::replace() with QRegExp capture modification
    By Lykurg in forum Qt Programming
    Replies: 1
    Last Post: 4th March 2008, 09:50
  5. Replies: 4
    Last Post: 31st January 2008, 20:44

Tags for this Thread

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.