Results 1 to 2 of 2

Thread: how to get the string out by multi separator?

  1. #1
    Join Date
    Oct 2007
    Posts
    32
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    3
    Thanked 3 Times in 3 Posts

    Default how to get the string out by multi separator?

    Hi,

    if there is a QSting str1 = 1111, aabbcc,"3,231,301", 33, "43,103,359", 32.335

    I know I can use str1.section(',' 0,0) to get the substring 1111 from str1. How can I get the substring "3,231,301" by QString section function? I think I should use QRegExp but don't know how to implement.


    Can somebody help? Thanks!

  2. #2
    Join Date
    Apr 2010
    Location
    Switzerland
    Posts
    16
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows
    Thanks
    3
    Thanked 1 Time in 1 Post

    Default Re: how to get the string out by multi separator?

    Qt Code:
    1. QString str = "1111, aabbcc,\"3,231,301\", 33, \"43,103,359\", 32.335";
    2. QRegExp rx("(,\"(\\d|,)*\",)");
    3. rx.indexIn(str);
    4. QStringList list = rx.capturedTexts();
    5. QString finalStr = list.at(0);
    To copy to clipboard, switch view to plain text mode 

    "finalStr" is what you wanted..

  3. The following user says thank you to Nik8768 for this useful post:

    SamT (18th April 2010)

Similar Threads

  1. Separator in box layout
    By drhex in forum Qt Programming
    Replies: 1
    Last Post: 30th September 2009, 22:36
  2. Separator in context menu
    By schall_l in forum Qt Programming
    Replies: 3
    Last Post: 18th June 2009, 17:09
  3. separator in QComboBox
    By dyams in forum Qt Programming
    Replies: 3
    Last Post: 7th March 2008, 09:56
  4. Is possible to hide a separator in a QToolBar?
    By Dark_Tower in forum Qt Programming
    Replies: 2
    Last Post: 20th April 2006, 10:03
  5. int to QString with thousands separator
    By klaus1111 in forum Newbie
    Replies: 6
    Last Post: 6th January 2006, 22:06

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.