PDA

View Full Version : getting images out of html



hijinks
15th June 2006, 22:45
I've been digging around the docs for a few hours.. I have chunks of html in QString and wondering if there is anyway to do like a regex to pull out something like <img *>

I saw find but that just returns the posistion.. I'd like to return all occurances of the regex to like a qstringlist

thanks!

jacek
15th June 2006, 23:17
Here's an example from the docs:
QString str = "offsets: 1.23 .50 71.00 6.00";
QRegExp rx( "\\d*\\.\\d+" ); // primitive floating point matching
int count = 0;
int pos = 0;
while ( (pos = rx.search(str, pos)) != -1 ) {
count++;
pos += rx.matchedLength();
}
// pos will be 9, 14, 18 and finally 24; count will end up as 4
You need something similar. QRegExp::cap( 0 ) should return the whole matched tag.