QRegularExpression not matching https://www.regextester.com/
-
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. -
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.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
-
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.@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 likeconst QRegularExpression testExp(QStringLiteral(R"**(<TEST>([a-zA-Z0-9 :\/.?_&=\-\(\)]+)<\/TEST>)**")); -
Hi,
To add to my fellow, you also have the QRegularExpression tool example that you can use to build and test regular expressions.