Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Condition in QRegExp
Forum Updated to NodeBB v4.3 + New Features

Condition in QRegExp

Scheduled Pinned Locked Moved General and Desktop
3 Posts 3 Posters 985 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • U Offline
    U Offline
    UriahHeep
    wrote on last edited by
    #1

    The following code is does not work. Why?
    @
    QRegExp *reg = new QRegExp("(?(x)y|z)"); // pattern: (?(if)then|else)
    qDebug() << reg->exactMatch("xy"); // return 'false'
    @

    1 Reply Last reply
    0
    • B Offline
      B Offline
      b1gsnak3
      wrote on last edited by
      #2

      try qDebug() << reg->isValid(); to see if the pattern is correct.

      Also I think the "?" should be at the end of the pattern.. Might be wrong, didn't use qregexp with ? as of yet

      1 Reply Last reply
      0
      • K Offline
        K Offline
        koahnig
        wrote on last edited by
        #3

        One thing you might want to try out is the regexp example. For learning a bit more of regexp and its behaviour it is quite handy.
        Check on *\examples\widgets\tools\regexp for Qt5.1.0 for Qt 4 it was under *\examples\tools\regexp

        Vote the answer(s) that helped you to solve your issue(s)

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved