Search code examples
c++regexqtqregexp

Qt and regular expressions


I would like to write simple regexp with Qt QRegExp

I want to fetch all substring of a Qstring with table(i, d), without the quotes, with i "hard written" and d representing any integer. And then using cap, to retrieve value for d. I propose

 qREgExp reg ( "table(i,\\s*(\\d+)\\s*)") ;

I cherrish the hope that then

 reg.cap(2)

gives me the d in question here.

How would you put it?


Solution

  • Try to use

    qREgExp reg ( "\\btable\\(i,\\s*(\\d+)\\s*\\)" );
    

    with

    reg.cap(1)