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. Qt regex modifier
Forum Updated to NodeBB v4.3 + New Features

Qt regex modifier

Scheduled Pinned Locked Moved Unsolved General and Desktop
15 Posts 4 Posters 6.0k Views 2 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.
  • Y Offline
    Y Offline
    yodusow bardon
    wrote on 20 Dec 2015, 01:33 last edited by yodusow bardon
    #1

    I'm trying to use a regex that uses \u modifier:

    (?:\\.(?:[a-z\\u00a1-\\uffff]{2,}))
    

    It would match strings like .com, the tld of an url, but when I call isValid() it returns false and when running I got this warning:

    QRegularExpressionPrivate::doMatch(): called on an invalid QRegularExpression object

    Is there a solution? What can I be doing in order to solve this?

    1 Reply Last reply
    0
    • M Offline
      M Offline
      mrjj
      Lifetime Qt Champion
      wrote on 20 Dec 2015, 09:02 last edited by
      #2

      @yodusow-bardon said:

      Hi
      I wonder if
      QRegularExpression::UseUnicodePropertiesOption 0x0040
      http://doc.qt.io/qt-5/qregularexpression.html
      is what you are after?

      ? 1 Reply Last reply 20 Dec 2015, 14:42
      0
      • M mrjj
        20 Dec 2015, 09:02

        @yodusow-bardon said:

        Hi
        I wonder if
        QRegularExpression::UseUnicodePropertiesOption 0x0040
        http://doc.qt.io/qt-5/qregularexpression.html
        is what you are after?

        ? Offline
        ? Offline
        A Former User
        wrote on 20 Dec 2015, 14:42 last edited by A Former User
        #3

        @mrjj I tried it too and it doesn't work. I my case I tried - it would match anything, including unicode characters:

        [a-z\u00a1-\uffff0-9]*
        

        And when calling isValid it returns false along with the same warning, even using UseUnicodePropertiesOption.

        M 1 Reply Last reply 20 Dec 2015, 14:52
        0
        • ? A Former User
          20 Dec 2015, 14:42

          @mrjj I tried it too and it doesn't work. I my case I tried - it would match anything, including unicode characters:

          [a-z\u00a1-\uffff0-9]*
          

          And when calling isValid it returns false along with the same warning, even using UseUnicodePropertiesOption.

          M Offline
          M Offline
          mrjj
          Lifetime Qt Champion
          wrote on 20 Dec 2015, 14:52 last edited by
          #4

          @Minupi said:
          hmm looking in
          qregularexpression.cpp
          I only see
          QT_TRANSLATE_NOOP("QRegularExpression", "PCRE does not support \L, \l, \N{name}, \U, or \u"),

          but at same time docs says "It fully supports Unicode"

          Does it work if u put the unicode directly in the string ?

          ? 1 Reply Last reply 20 Dec 2015, 15:04
          0
          • M mrjj
            20 Dec 2015, 14:52

            @Minupi said:
            hmm looking in
            qregularexpression.cpp
            I only see
            QT_TRANSLATE_NOOP("QRegularExpression", "PCRE does not support \L, \l, \N{name}, \U, or \u"),

            but at same time docs says "It fully supports Unicode"

            Does it work if u put the unicode directly in the string ?

            ? Offline
            ? Offline
            A Former User
            wrote on 20 Dec 2015, 15:04 last edited by A Former User
            #5

            @mrjj I might, but the thing is that I need to use \u as it has a range: \uffff0-9.

            I think that I'm going to drop the QRegularExpression and use QRegExp instead.

            M 1 Reply Last reply 20 Dec 2015, 15:07
            0
            • ? A Former User
              20 Dec 2015, 15:04

              @mrjj I might, but the thing is that I need to use \u as it has a range: \uffff0-9.

              I think that I'm going to drop the QRegularExpression and use QRegExp instead.

              M Offline
              M Offline
              mrjj
              Lifetime Qt Champion
              wrote on 20 Dec 2015, 15:07 last edited by
              #6

              @Minupi said:
              Well if it just accepts a \u I agree it seems more sensible than to figure out how to do \u like with QRegularExpression.

              ? 1 Reply Last reply 20 Dec 2015, 15:13
              0
              • M mrjj
                20 Dec 2015, 15:07

                @Minupi said:
                Well if it just accepts a \u I agree it seems more sensible than to figure out how to do \u like with QRegularExpression.

                ? Offline
                ? Offline
                A Former User
                wrote on 20 Dec 2015, 15:13 last edited by
                #7

                @mrjj It's kinda nonsense as QRegularExpresion came to be better than QRegExp, but anyway, let's stick with it as it's the only option left here.

                Thank you.

                M 1 Reply Last reply 20 Dec 2015, 15:21
                1
                • ? A Former User
                  20 Dec 2015, 15:13

                  @mrjj It's kinda nonsense as QRegularExpresion came to be better than QRegExp, but anyway, let's stick with it as it's the only option left here.

                  Thank you.

                  M Offline
                  M Offline
                  mrjj
                  Lifetime Qt Champion
                  wrote on 20 Dec 2015, 15:21 last edited by
                  #8

                  @yodusow-bardon said:
                  btw
                  did u try
                  \x{FFFF}

                  ? 2 Replies Last reply 20 Dec 2015, 15:36
                  1
                  • M mrjj
                    20 Dec 2015, 15:21

                    @yodusow-bardon said:
                    btw
                    did u try
                    \x{FFFF}

                    ? Offline
                    ? Offline
                    A Former User
                    wrote on 20 Dec 2015, 15:36 last edited by
                    #9

                    @mrjj Yes, I did and I got an error saying:

                    hex constants must have at least one hex digit

                    1 Reply Last reply
                    1
                    • M mrjj
                      20 Dec 2015, 15:21

                      @yodusow-bardon said:
                      btw
                      did u try
                      \x{FFFF}

                      ? Offline
                      ? Offline
                      A Former User
                      wrote on 20 Dec 2015, 15:42 last edited by
                      #10

                      @mrjj I fixed it, and it's working now... You just have to escape the \x, like \\x, for instance: [a-z\\x{00a1}-\\x{ffff}0-9]*.

                      M 1 Reply Last reply 20 Dec 2015, 15:43
                      0
                      • ? A Former User
                        20 Dec 2015, 15:42

                        @mrjj I fixed it, and it's working now... You just have to escape the \x, like \\x, for instance: [a-z\\x{00a1}-\\x{ffff}0-9]*.

                        M Offline
                        M Offline
                        mrjj
                        Lifetime Qt Champion
                        wrote on 20 Dec 2015, 15:43 last edited by mrjj
                        #11

                        @Minupi
                        Oh yes always escape "\"
                        Super- :)

                        ? 1 Reply Last reply 20 Dec 2015, 15:44
                        1
                        • M mrjj
                          20 Dec 2015, 15:43

                          @Minupi
                          Oh yes always escape "\"
                          Super- :)

                          ? Offline
                          ? Offline
                          A Former User
                          wrote on 20 Dec 2015, 15:44 last edited by
                          #12

                          @mrjj Thank you, helped a lot. I realised that QRegularExpression is using the same syntax as PHP.

                          M 1 Reply Last reply 20 Dec 2015, 15:46
                          0
                          • ? A Former User
                            20 Dec 2015, 15:44

                            @mrjj Thank you, helped a lot. I realised that QRegularExpression is using the same syntax as PHP.

                            M Offline
                            M Offline
                            mrjj
                            Lifetime Qt Champion
                            wrote on 20 Dec 2015, 15:46 last edited by
                            #13

                            @Minupi
                            Good to hear. :)
                            It says its perl syntax but maybe PHP uses perl style or reverse?

                            ? 1 Reply Last reply 20 Dec 2015, 15:47
                            0
                            • M mrjj
                              20 Dec 2015, 15:46

                              @Minupi
                              Good to hear. :)
                              It says its perl syntax but maybe PHP uses perl style or reverse?

                              ? Offline
                              ? Offline
                              A Former User
                              wrote on 20 Dec 2015, 15:47 last edited by
                              #14

                              @mrjj Yes, it resembles perl style, it's called PCRE.

                              1 Reply Last reply
                              1
                              • SGaistS Offline
                                SGaistS Offline
                                SGaist
                                Lifetime Qt Champion
                                wrote on 21 Dec 2015, 00:21 last edited by
                                #15

                                Hi,

                                To help you with your regular expression development, you can use the regular expression tool. It's available starting with Qt 5.6

                                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
                                1

                                1/15

                                20 Dec 2015, 01:33

                                • Login

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