Results 1 to 4 of 4

Thread: Two Word QRegExp Help

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Apr 2008
    Posts
    6
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Two Word QRegExp Help

    I'm having a problem setting up a two word QRegExp. In Example #1 I'm able to pick out USER from str1. However, in Example #2 I'm not able to pick out USER ACTION:
    What am I doing wrong? Thanks!


    EXAMPLE #1:
    Qt Code:
    1. QString str = "User Action:";
    2. QString str1 = "USER ACTION:";
    3.  
    4. QRegExp reg ("^\\bUSER\\b");
    5.  
    6. int ireturn = reg.indexIn(str, 0);
    7. std::cout << ireturn << std::endl;
    8. ireturn = reg.indexIn(str1, 0);
    9. std::cout << ireturn << std::endl;
    10. QString captured = reg.cap( 0 ); // captured == "letter"
    11. std::cout << captured.toStdString() << std::endl;
    To copy to clipboard, switch view to plain text mode 

    EXAMPLE #2:
    Qt Code:
    1. QString str = "User Action:";
    2. QString str1 = "USER ACTION:";
    3.  
    4. QRegExp reg ("^\\bUSER\\b\\s\\bACTION:\\b");
    5.  
    6. int ireturn = reg.indexIn(str, 0);
    7. std::cout << ireturn << std::endl;
    8. ireturn = reg.indexIn(str1, 0);
    9. std::cout << ireturn << std::endl;
    10. QString captured = reg.cap( 0 ); // captured == "letter"
    11. std::cout << captured.toStdString() << std::endl;
    To copy to clipboard, switch view to plain text mode 
    Last edited by jpn; 13th May 2008 at 13:48. Reason: changed [indent] to [code] tags

Similar Threads

  1. invoking microsoft word from qt
    By omprakash in forum Qt Programming
    Replies: 2
    Last Post: 31st October 2007, 20:43
  2. QRegExp Help
    By Ahmad in forum Qt Programming
    Replies: 2
    Last Post: 28th May 2007, 00:13
  3. Word wrapping in a QTableWidget cell
    By jcooperddtd in forum Qt Programming
    Replies: 3
    Last Post: 1st May 2007, 03:57
  4. QRegExp progblem
    By high_flyer in forum Qt Programming
    Replies: 1
    Last Post: 6th September 2006, 12:12
  5. need help for my QRegExp
    By patcito in forum Qt Programming
    Replies: 1
    Last Post: 27th May 2006, 16:29

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.