#include <QCoreApplication>
#include <QtCore>
int main(int argc, char *argv[])
{
//case double qoute delimeter
QString test
("\"apple\" \"orange\" \"fig\"");
qDebug()<< s;
//using Regexp
QString v
=" Abcd(efhj:xyz; abc:\" hello\"; pqr:\"hi\")";
int pos = 0;
while ((pos = rx.indexIn(v, pos)) != -1)
{
list << rx.cap(0);
pos += rx.matchedLength();
}
//qDebug()<<list;
qDebug()<<str;
return a.exec();
}
#include <QCoreApplication>
#include <QtCore>
int main(int argc, char *argv[])
{
//case double qoute delimeter
QString test("\"apple\" \"orange\" \"fig\"");
QStringList splits=test.split("\" \"",QString::SkipEmptyParts);
foreach(QString s,splits)
qDebug()<< s;
//using Regexp
QString v=" Abcd(efhj:xyz; abc:\" hello\"; pqr:\"hi\")";
QRegExp rx("\"([^\"]*)\"");
QStringList list;
int pos = 0;
while ((pos = rx.indexIn(v, pos)) != -1)
{
list << rx.cap(0);
pos += rx.matchedLength();
}
//qDebug()<<list;
foreach(QString str,list)
qDebug()<<str;
QCoreApplication a(argc, argv);
return a.exec();
}
To copy to clipboard, switch view to plain text mode
Bookmarks