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");

    QString const target = "<font color=\"#cc1105\" size=+1><b>氷菓  第18話「連峰は晴れているか」</b></font>";
    QRegExp exp("<font color=\"#cc1105\" size=\\+1><b>\\p{L}+</b></font>");   
    QTextEdit editor;


    "\p{L}" , "[.]+ " can't work either

  • If you just want to split the string and delete empty space, use "QString::split":

    Note that the output give you a "QStringList":, 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>");
    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?

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.