Results 1 to 3 of 3

Thread: QStringList.filter using RegExp

  1. #1
    Join Date
    Jul 2007
    Posts
    27
    Thanks
    10
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default QStringList.filter using RegExp

    I get a list of tables from my database into a QStringList, I want to use QStringList's filter function to list all tables EXCEPT those that begin with "sqlite", how can I do this with filter, using RegExp?

    Here's what I'm currently trying:

    Qt Code:
    1. QStringList tables = database.tables(tableType); // tableType = QSql::Tables
    2. QStringList ret_tables = tables.filter(QRegExp("^sqlite{0,0}", Qt::CaseInsensitive));
    To copy to clipboard, switch view to plain text mode 

    When I do this, my ret_tables ends up completely blank.

    So basically I want to know how to do a RegExp filter which will match everything except strings beginning with "sqlite".

  2. #2
    Join Date
    Oct 2006
    Posts
    279
    Thanks
    6
    Thanked 40 Times in 39 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QStringList.filter using RegExp

    "(?!sqlite).*" should work.

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

    grellsworth (7th August 2007)

  4. #3
    Join Date
    Jul 2007
    Posts
    27
    Thanks
    10
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QStringList.filter using RegExp

    This seems to work, also:

    Qt Code:
    1. QStringList tables = database.tables(tableType);
    2. StringList ret_tables = tables.filter(QRegExp("^(?!sqlite_)", Qt::CaseInsensitive));
    To copy to clipboard, switch view to plain text mode 

    Thanks, spud.

Similar Threads

  1. Quick RegExp question
    By stealth86 in forum Qt Programming
    Replies: 3
    Last Post: 26th July 2007, 08:23

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.