Qt World Summit: Submit your Presentation

How to include variable name in QRegExp

  • Hi,
    How can i include variable in a regular expression?
    Actually i want to search a word in a text file.(exact match of the word)
    The word is entered through lineedit.
    Hence i used

    QRegExp rx("\stext");

    But that is not working..
    here text is the variable, i want only the exact match of the word in the file.
    How can i declare that?

  • Hi,

    try this:

    QString pattern = QString("\s%1").arg(text);
    QRegExp rx(pattern);

  • Thanks for ur reply.....i did it...:)

Log in to reply