I gotta be doing something stupid here. Can anyone lend another pair of eyes?
QString crap = "[01;32msshtest@router[01;34m / $[00m";
Given the above text, I wish to parse out the numbers right after the initial '['
In other words, I want to match this list:
01;
32m
01;
34m
00m
Here's the code:
QRegExp regEx
( "(([0-9]+)[;|m])+");
int pos = 0;
while ( (pos = regEx.indexIn( crap, pos)) != -1)
{
matches << regEx.cap(1);
printf( "Matched: %s\n", regEx.cap(1).toLatin1().constData() );
pos += regEx.matchedLength() -1;
}
QRegExp regEx( "(([0-9]+)[;|m])+");
int pos = 0;
QStringList matches;
while ( (pos = regEx.indexIn( crap, pos)) != -1)
{
matches << regEx.cap(1);
printf( "Matched: %s\n", regEx.cap(1).toLatin1().constData() );
pos += regEx.matchedLength() -1;
}
To copy to clipboard, switch view to plain text mode
This is what I get when its run:
Matched: 32m
Matched: 34m
Matched: 00m
Umm.... why in the world is it not matching the stuff with ';'s ?
Paul
Bookmarks