Unsolved How to pass reguaklr expression - from string list ?
-
Another C++ code under construction and I need advise.
cursor = document->find(str); will accept regular expression , but I am passing plain QString. That is no go.
I like to keep that QString in QStringList , but I do not know how and where to build regular expression - in foreach loop. .
I did try - replacing the QString , but that is wrong - it breaks the QStringList .
QRegularExpression re( [0-F]{2}[:]){5}[0-F]{2}", "([0-F]{2}[:] ) ;
QStringList BT_Setup[16] = {{ "controller","Powered: yes","Discoverable: no","Pairable: no","Discovering: no", "([0-F]{2}[:]){5}[0-F]{2}", "([0-F]{2}[:])" }, { "contoller", "Remote", "Control"}, { "contoller", "Remote", "Control"} }; QTextDocument * document = ui->textEdit_35->document(); QTextCursor cursor = ui->textEdit_35->textCursor(); QTextCharFormat fmt = cursor.charFormat(); fmt.setBackground(Qt::green); foreach(str, BT_Setup[0]) { // foreach block qDebug() << "DEBUG POINT " << QString::number(__LINE__); qDebug() << "DEBUG POINT " << str; convert str to regular expression here ?? cursor = document->find(str); if(cursor.isNull()) { qDebug() << "FAILED DEBUG POINT " << QString::number(__LINE__); qDebug() << "DEBUG POINT " << str; } cursor.setCharFormat(fmt); }// foreach block
-
Hi
Since QRegularExpression has a constructor that takes a QString ,
cant you just sayQRegularExpression exp(str); cursor = document->find( exp);
-
@mrjj Perfect - I just cannot think as a compiler - plain string as regular expression....
SOLVED