What is the qt regular expression to capture the text inside a parentheses?
-
hi all,
I needed to capture the text inside a parentheses.
For eg:
hello how are u mr(abc+d) joyhere i want to capture the text "abc+d"
how can i do that?
i tried but i didnt get how to use parentheses....
please some one guide me -
You will have to escape the parentheses using \.
@
QString text("hello how are u mr(abc+d) joy");QRegExp exp("\\((.*)\\)"); if(exp.indexIn(text) >= 0) { qDebug() << exp.cap(0); // "(acb+d)" qDebug() << exp.cap(1); // "abc+d" }
@