I have a QPlainTextEdit
and want to select specific text in it using QRegExp
here is example of a text block:
Block1 = Foo1 {
bla bla bla;
bla bla bla;
}
I need to select starting from =
till }
given the sub-string Foo1
Here is my code:
QString name = "Foo1";
QString pattern = "[\\=][\\s]" + name + "[\\s][\\{](^\\})*[\\}]";
//pattern = "[\=][\s]Foo1[\s][\{](^\})*[\}]"
and these lines for selection:
this->moveCursor(QTextCursor::Start);
this->document()->find(QRegExp(pattern));
and strangely, this select only Foo1
not
= Foo1 {
bla bla bla;
bla bla bla;
}