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. Called on an invalid QRegularExpression object warning

Called on an invalid QRegularExpression object warning

Scheduled Pinned Locked Moved Solved General and Desktop
8 Posts 2 Posters 4.0k Views
  • 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.
  • S Offline
    S Offline
    samzhcs1
    wrote on last edited by A Former User
    #1

    QRegularExpression re2("^=?[a-z1-9A-Z\s+-*/]*");
    QRegularExpressionMatch mat = re2.match(tst);

    The above code generated called on an invalid QRegularExpression object warning, while the following code works well.
    QRegularExpression re3("\\");
    QRegularExpressionMatch mat = re3.match(tst);

    But I tried with :
    QString pattern("^=?[a-z1-9A-Z\s+-*/]*");
    QRegExp rx(pattern);
    bool match = rx.exactMatch(tst);
    then it works well.

    Anybody know the reason?

    Thanks

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      Your first star is the problem.

      What exactly are you trying to search ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • S Offline
        S Offline
        samzhcs1
        wrote on last edited by samzhcs1
        #3

        0_1478389043186_upload-106c3fc1-acca-449e-806a-07964e202279
        should be this expression, don't know why when I posted it, browser seems removed some backslashes

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Still your first * is the problem. Hence my question, what do you want to extract exactly with your expression ?

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          S 1 Reply Last reply
          0
          • S Offline
            S Offline
            samzhcs1
            wrote on last edited by
            #5

            I want to match the following string:
            Number, 1 2 3 ..
            and A1 b3 C3 ..M19 ..
            formula: =A1+B1 / c3 ...

            1 Reply Last reply
            0
            • SGaistS SGaist

              Still your first * is the problem. Hence my question, what do you want to extract exactly with your expression ?

              S Offline
              S Offline
              samzhcs1
              wrote on last edited by
              #6

              @SGaist then how can I put a Arithmetic operator * in the expression?

              1 Reply Last reply
              0
              • SGaistS Offline
                SGaistS Offline
                SGaist
                Lifetime Qt Champion
                wrote on last edited by
                #7

                ^=?[a-z1-9A-Z\s*/+-]*

                You can use the regular expression tool from Qt's example to test your regular expressions with Qt.

                Interested in AI ? www.idiap.ch
                Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                1 Reply Last reply
                0
                • S Offline
                  S Offline
                  samzhcs1
                  wrote on last edited by
                  #8

                  It's the \ escaped character reason.

                  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