Pregunta

He escrito

QRegExp rx("<img src=\"\\S+\"\\s+width=\"(\\d+)\"\\s+height\"(\\d+)\"\\s+/>");

RegExp con el fin de que coincida

 <img src="file://c/Users/Narek/Desktop/WClub.jpg" width="95" height="113.04" />

tipo de subcadena en una cadena, con el fin de extraer la anchura y la altura. Pero esto no coincide. Por favor, dime lo que tengo mal hecho.

¿Fue útil?

Solución

The last \d doesn't take account of the dot inside the number, and you are missing '=' after 'height'.

Otros consejos

\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.

What about :

QRexExp rx("<img src=[^<]+/\> ");

Hope it helps !

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top