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. A regex doesn't work
Forum Updated to NodeBB v4.3 + New Features

A regex doesn't work

Scheduled Pinned Locked Moved General and Desktop
3 Posts 3 Posters 897 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.
  • B Offline
    B Offline
    bagipro
    wrote on last edited by
    #1

    @QString str = "[[["123"";
    QRegExp rx("[[["([^"]+)"");
    rx.indexIn(str,0);
    cout << rx.cap(1).toStdString();@
    Why it doesn't output 123 in console?

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

      There is a "regexp example application":http://qt-project.org/doc/qt-5.0/qtwidgets/tools-regexp.html coming with Qt. I found it quite helpful in trying to find regexp issues.

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

      1 Reply Last reply
      0
      • C Offline
        C Offline
        ChrisW67
        wrote on last edited by
        #3

        Your regular expression is invalid. After the C-string escapes are stripped you get:
        @
        [[["([^"]+)"
        @
        when what you were expecting is more like:
        @
        [[["([^"]+)"
        @

        Try:
        @
        QRegExp rx("\[\[\["([^"]+)"");
        @

        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