QRegExp for everything inside [ ]



  • Well, i have some issues with QRegExp (They're not friendly with me!) I just want to know the QRegExp for everything inside [ ], like the one for Quotations (QRegExp("".*"")) but for [ ] instead.



  • You'll just have to escape <code>[</code> and <code>]</code> within your pattern, as they are used to group expressions.
    @
    QRegExp pattern("[.*]"); // double slash, as you want to escape the
    // brackets within your pattern, not within
    // the string passed to the ctor
    @
    Be aware that if there are nested brackets you'll receive a greedy match, as QRegExp::setMinimal() is false per default.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.