Need help for QRegExp(unicode)
-
I want to parse the string by QString, but don't know how to deal with
consecutive unicode@
QTextCodec *codec = QTextCodec::codecForName("UTF-8");
QTextCodec::setCodecForLocale(codec);
QTextCodec::setCodecForCStrings(codec);QString const target = "<font color=\"#cc1105\" size=+1><b>氷菓 第18話「連峰は晴れているか」</b></font>"; QRegExp exp("<font color=\"#cc1105\" size=\\+1><b>\\p{L}+</b></font>"); exp.indexIn(target); QTextEdit editor; editor.append(exp.cap(0)); editor.append(exp.cap(1)); editor.show();
@
"\p{L}" , "[.]+ " can't work either
-
If you just want to split the string and delete empty space, use "QString::split":http://qt-project.org/doc/qt-4.8/qstring.html#split.
Note that the output give you a "QStringList":http://qt-project.org/doc/qt-4.8/qstringlist.html, which turn out to be just what you need to handle "consecutive" string.
-
Thanks, but QString::split is not flexible enough for my requirement
The doc say QRegExp support unicode, but I don't know
how to manage unicode by QRegExp -
@
QString const target = "<font color="#cc1105" size=+1><b>氷菓 第18話「連峰は晴れているか」</b></font>";
QRegExp exp("<font color="#cc1105" size=\+1><b>([^<]+)</b></font>");
exp.indexIn(target);
qDebug() << exp.cap(0) << endl << exp.cap(1);
@I find out another solution, use ([^<]+) to catch the words
QRegExp do not support "\p{L}" yet?