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. QRegularExpression not matching https://www.regextester.com/
Forum Updated to NodeBB v4.3 + New Features

QRegularExpression not matching https://www.regextester.com/

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 4 Posters 672 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.
  • L Offline
    L Offline
    Laurent Schall
    wrote on last edited by VRonin
    #1

    I am trying to describe a QRegularExpression for matching the following string: <TEST>:/My-System/Mechanical/General Design (A123).para/query?column=Name</TEST> is it working in https://www.regextester.com/ with <TEST>([a-zA-Z0-9 :/.?_&=\-\(\)]+)<\/TEST> but seems not to work with QRegularExpression.

    I guess I have some issues

    • or with the parentheses (A123) described as ( and )
    • or with the minus sign My-System described as -
    • or with the backslash </TEST> described as </TEST>

    My regular expression <TEST>([a-zA-Z0-9 :/.?_&=\-\(\)]+)<\/TEST> is working to test <TEST>:/My-System/Mechanical/General Design (A123).para/query?column=Name</TEST> in https://www.regextester.com/ but not in my Qt application.

    aha_1980A VRoninV 2 Replies Last reply
    0
    • L Laurent Schall

      I am trying to describe a QRegularExpression for matching the following string: <TEST>:/My-System/Mechanical/General Design (A123).para/query?column=Name</TEST> is it working in https://www.regextester.com/ with <TEST>([a-zA-Z0-9 :/.?_&=\-\(\)]+)<\/TEST> but seems not to work with QRegularExpression.

      I guess I have some issues

      • or with the parentheses (A123) described as ( and )
      • or with the minus sign My-System described as -
      • or with the backslash </TEST> described as </TEST>

      My regular expression <TEST>([a-zA-Z0-9 :/.?_&=\-\(\)]+)<\/TEST> is working to test <TEST>:/My-System/Mechanical/General Design (A123).para/query?column=Name</TEST> in https://www.regextester.com/ but not in my Qt application.

      aha_1980A Offline
      aha_1980A Offline
      aha_1980
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi @Laurent-Schall,

      have you tried adding the separators ^ and $ to your regex?

      or with the backslash </TEST> described as </TEST>

      Note: that's no backslash, but a forward slash. Backslashes you would indeed have to escape in a C++ string.

      Regards

      Qt has to stay free or it will die.

      1 Reply Last reply
      1
      • L Laurent Schall

        I am trying to describe a QRegularExpression for matching the following string: <TEST>:/My-System/Mechanical/General Design (A123).para/query?column=Name</TEST> is it working in https://www.regextester.com/ with <TEST>([a-zA-Z0-9 :/.?_&=\-\(\)]+)<\/TEST> but seems not to work with QRegularExpression.

        I guess I have some issues

        • or with the parentheses (A123) described as ( and )
        • or with the minus sign My-System described as -
        • or with the backslash </TEST> described as </TEST>

        My regular expression <TEST>([a-zA-Z0-9 :/.?_&=\-\(\)]+)<\/TEST> is working to test <TEST>:/My-System/Mechanical/General Design (A123).para/query?column=Name</TEST> in https://www.regextester.com/ but not in my Qt application.

        VRoninV Offline
        VRoninV Offline
        VRonin
        wrote on last edited by VRonin
        #3

        @Laurent-Schall said in QRegularExpression not matching https://www.regextester.com/:

        it working in https://www.regextester.com/ with <TEST>([a-zA-Z0-9 :/.?_&=\-\(\)]+)<\/TEST>

        If you input that in https://regex101.com/ it shows you what the error is. you are missing one escape. The correct regexp is <TEST>([a-zA-Z0-9 :\/.?_&=\-\(\)]+)<\/TEST> that goes into your code as something like const QRegularExpression testExp(QStringLiteral(R"**(<TEST>([a-zA-Z0-9 :\/.?_&=\-\(\)]+)<\/TEST>)**"));

        "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
        ~Napoleon Bonaparte

        On a crusade to banish setIndexWidget() from the holy land of Qt

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

          Hi,

          To add to my fellow, you also have the QRegularExpression tool example that you can use to build and test regular expressions.

          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
          5

          • Login

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