Results 1 to 2 of 2

Thread: QRegExp

  1. #1
    Join Date
    Dec 2006
    Posts
    9
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default QRegExp

    "TOTAL : <COUNT> LINE."

    I want split only <COUNT> with QRegExp, how can do this ?

  2. #2
    Join Date
    Jun 2007
    Location
    Cambridge, United Kingdom
    Posts
    5
    Thanked 2 Times in 2 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QRegExp

    Try the following code:

    Qt Code:
    1. QString line1("TOTAL: 534 LINE.");
    2. QRegExp rx("TOTAL: (\\d+) LINE.");
    3. if (rx.indexIn(line1) != -1) {
    4. qDebug() << "count in line1 = " << rx.cap(1);
    5. }
    To copy to clipboard, switch view to plain text mode 

    The important thing are the parentheses around "(\\d+)", which capture the matching text. You can access this text with cap() as shown.

    Cheers,
    Burkhard
    Last edited by jpn; 3rd August 2008 at 19:21. Reason: missing [code] tags

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

    tebessum (3rd August 2008)

Similar Threads

  1. Two Word QRegExp Help
    By mabeeh in forum Qt Programming
    Replies: 3
    Last Post: 13th May 2008, 14:29
  2. QRegExp Help
    By Ahmad in forum Qt Programming
    Replies: 2
    Last Post: 28th May 2007, 00:13
  3. QRegExp progblem
    By high_flyer in forum Qt Programming
    Replies: 1
    Last Post: 6th September 2006, 12:12
  4. need help for my QRegExp
    By patcito in forum Qt Programming
    Replies: 1
    Last Post: 27th May 2006, 16:29
  5. 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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.