QRegExp problem
I have written
QRegExp rx("<img src=\"\\S+\"\\s+width=\"(\\d+)\"\\s+height\"(\\d+)\"\\s+/>");
Reg开发者_如何转开发Exp in order to match
<img src="file://c/Users/Narek/Desktop/WClub.jpg" width="95" height="113.04" />
kind of substring in a string, in order to extract the width and height. But this does not match. Please tel me what I have done wrong.
\d
does not match the period in your height.
A regular expression that would work would be something like:
<img src=\"[^"]*\"\s+width=\"(\d+(?:\.\d+)?)\"\s+height=\"(\d+(?:\.\d+)?)\"\s+/>
Also, the obligatory comment that it is a bad idea to parse HTML using Regex.
The last \d
doesn't take account of the dot inside the number, and you are missing '=' after 'height'.
What about :
QRexExp rx("<img src=[^<]+/\> ");
Hope it helps !
精彩评论