Details
-
Bug
-
Resolution: Invalid
-
Not Evaluated
-
None
-
5.2.0
-
None
-
MSVC 2013, Windows 8.1
Description
I have a string "foo + bar". I attempt to write a regular expression matching the free-standing "+" operator.
However, my initial attempt QRegularExpression("\\b\\+
b") didn't succeed — it fails to match to the said string.
If I replace "
+" with "a", it works. If I replace "
b" with " " (space), it works (but does different thing than I wanted). So apparently both parts are fine on their own, they fail only when composed together.
Please consider the following source code snippet:
const QString textA = "foo a bar"; const QRegularExpression regexpA("\\ba\\b"); const QString textPlus = "foo + bar"; const QRegularExpression regexpPlus("\\+"); const QRegularExpression regexpPlusEnclosed("\\b\\+\\b"); assert(regexpA.globalMatch(textA).hasNext()); // OK assert(regexpPlus.globalMatch(textPlus).hasNext()); // OK assert(regexpPlusEnclosed.globalMatch(textPlus).hasNext()); // FAILURE
I believe all three matches should succeed, while the third one fails.