jshafferman
10th April 2012, 21:00
I am having problems getting a QRegExp to read the character '-'. I have a program that reads in QString and that string has to be in a specific order for the program to be able to label it correclty. Here is what I have so far:
QString itemReadIn = "SFPP-----------";
QRegExp exp("S?F?------?????");
exp.setPatternSyntax(QRegExp::Wildcard);
if(exp.exactMatch(itemReadIn))
{
// label item correctly
return;
}
So my probelm is that the if statement is never entered into so the labeling never happens correctly. I thought my expression was correct but I haven't been able to figure out why it won't work. I have also trie \\- for - and that doesn't seem to do anything to help :(. It is my understanding that the ? means any character which is exactly what I want and the '-' should be literally that character nothing else.
Any help would be greatly appreciated. Thanks!!
QString itemReadIn = "SFPP-----------";
QRegExp exp("S?F?------?????");
exp.setPatternSyntax(QRegExp::Wildcard);
if(exp.exactMatch(itemReadIn))
{
// label item correctly
return;
}
So my probelm is that the if statement is never entered into so the labeling never happens correctly. I thought my expression was correct but I haven't been able to figure out why it won't work. I have also trie \\- for - and that doesn't seem to do anything to help :(. It is my understanding that the ? means any character which is exactly what I want and the '-' should be literally that character nothing else.
Any help would be greatly appreciated. Thanks!!