#include <QCoreApplication>
#include <QRegExp>
#include <QDebug>
int main(int argc, char *argv[])
{
QRegExp rx1
("(ftp:|http:|https:){0}//([a-zA-Z0-9_-]+)");
QRegExp rx2
("[^(ftp:|http:|https:)]//([a-zA-Z0-9_-]+)");
QRegExp rx3
("(?=(ftp:|http:|https:))//([a-zA-Z0-9_-]+)");
QRegExp rx4
("(?!(ftp:|http:|https:))//([a-zA-Z0-9_-]+)");
strData = "//aaa";
// should be != -1
qDebug() << "1:" << rx1.indexIn(strData) << " " << (rx1.indexIn(strData) != -1 ? "OK" : "WRONG");
qDebug() << "2:" << rx2.indexIn(strData) << " " << (rx2.indexIn(strData) != -1 ? "OK" : "WRONG");
qDebug() << "3:" << rx3.indexIn(strData) << " " << (rx3.indexIn(strData) != -1 ? "OK" : "WRONG");
qDebug() << "4:" << rx4.indexIn(strData) << " " << (rx4.indexIn(strData) != -1 ? "OK" : "WRONG");
qDebug() << "";
strData = "http://aaa";
// should be == -1
qDebug() << "1:" << rx1.indexIn(strData) << " " << (rx1.indexIn(strData) == -1 ? "OK" : "WRONG");
qDebug() << "2:" << rx2.indexIn(strData) << " " << (rx2.indexIn(strData) == -1 ? "OK" : "WRONG");
qDebug() << "3:" << rx3.indexIn(strData) << " " << (rx3.indexIn(strData) == -1 ? "OK" : "WRONG");
qDebug() << "4:" << rx4.indexIn(strData) << " " << (rx4.indexIn(strData) == -1 ? "OK" : "WRONG");
// rx.cap ... etc
return a.exec();
}