Reputation: 596
I would like to match only the following pattern:
/a
/b
/c
and others should return false:
/a/foo
/bX
/c23
etc.
For this I have the following code:
QRegExp navigation("^/(a|b|c)\b");
However navigation.indexIn(str)
returns -1
How should I modify the code so that this returns a positive value?
Upvotes: 1
Views: 161
Reputation: 4897
Have you already tried:
^/(a|b|c)$
With this regex engine you need to change it to:
/^\/(a|b|c)$/gm
As Spidey wrote also this works:
/^\/[abc]$/gm
Upvotes: 1
Reputation: 91488
Not really sure nut I think you have to double escape the word boundary:
QRegExp navigation("^/(a|b|c)\\b");
Upvotes: 0