[solved]QRegExp
-
Hellow, i have this code:
@if (rgb.contains(QRegExp("[0-9a-fA-F]{1,3},[0-9a-fA-F]{1,3},[0-9a-fA-F]{1,3}")))@
program should recognize the RGB arguments, but it does not work, whereas if you check here http://gskinner.com/RegExr/, then everything works fine, instead of trying to write \, - does not work -
You need to set Greedy flag on and use QRegexp2 syntax.
To clarify:
@
QRegexp re("[0-9a-fA-F]{1,3},[0-9a-fA-F]{1,3},[0-9a-fA-F]{1,3}");
re.setMinimal (false);@ -
Wouldn't this regexp match "FFF,FFF,FFF" - which is definitly not a valid RGB value - too?
-
You are doing something wrong. I tested and it matches:
!http://s1.picofile.com/file/6870501006/screenshot16.png(test)!
@[0-9a-fA-F]{1,2}@ also won't work for validating rgb hex values. Could you give your regexp declaration code?
-
If i write
@ QRegExp re("[0-9a-fA-F]{1,3},[0-9a-fA-F]{1,3},[0-9a-fA-F]{1,3}");
re.setMinimal(true);
if (rgb.contains(re))@
It is doesnt work too -
While I think
@"[0-9a-fA-F]{2},[0-9a-fA-F]{2},[0-9a-fA-F]{2}"@
will be a better choice, your expression works for me with Regexp and Regexp2 syntaxes.Setting greedy mode to on means set minimal to of...;) you should:
@
re.setMinimal(false);
@