I'm currently working on a small program where I will count the amount of times a certain word is mentioned in a text. But I only want to count for the word when the previous element is a 10 digit number. So what I'm trying is do is that I will check if the previous element of the iterator consist of a 10 digit number. But I don't know how to iterate to the previous element from the iterator.
QString input = ui->listinput->toPlainText();
QStringList inputlist = input.split(QRegExp("[\s\n\r " "]+"));
unsigned int boxCount(0);
for(QStringList::iterator it(inputlist.begin()); it != inputlist.end(); ++it){
if(!QString::compare(*it,box)) ++boxCount;
}
So I want the if statement to be something like this:
if(!QString::compare(*it,box) && *prev_it == 10 digits) ++boxCount;
Any help will be appreciated. Thanks!