So I have got a string in my app which contains an html img tag
<img src="imagsource.jpg" width="imageWidth" />
Now I want to extract the image tag and its src
attribute in two different strings. So what I tried to do is this:
QRegExp imageRegex("\\<img[^\\>]*src\\s*=\\s*\"([^\"]*)\"[^\\>]*\\>", Qt::CaseInsensitive);
int a = imageRegex.indexIn(description);
int b = a + imageRegex.matchedLength();
QString imgTag = description.mid(a,b); // this kind of works but doesn't return the img tag properly (extra information is included)
// how to obtain the "src" attribute, I have tried this: src\s*=\s*\"(.+?)" but it doesn't work
QString imgSrc = ??
I have tried to look at other posts regarding how to extract strings from other string using regex, I have tried to use the same patterns in QRegExp
but they don't seem to give the correct result.