View Full Version : QStringList.filter using RegExp

6th August 2007, 17:40
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:

QStringList tables = database.tables(tableType); // tableType = QSql::Tables
QStringList ret_tables = tables.filter(QRegExp("^sqlite{0,0}", Qt::CaseInsensitive));

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".

7th August 2007, 01:01
"(?!sqlite).*" should work.

7th August 2007, 15:09
This seems to work, also:

QStringList tables = database.tables(tableType);
StringList ret_tables = tables.filter(QRegExp("^(?!sqlite_)", Qt::CaseInsensitive));

Thanks, spud.