I have a QString that I need to parse. This QString is a QNetworkReply object obtained from an URL.

        <label id='Today_LastSale1'>$&nbsp;21.2401</label>

I need the value 21.2401 from the QString.

I am tried this.

       QRegExp rx("<label id='Today_LastSale1'>$&nbsp;(\\d)</label>");

But it returns -1. Need help with this.

Thanks in Advance!

有帮助吗?

解决方案

You can just try to remove the non-numeric and "." characters from your string. Try regex replace with this expression: "[^0-9\.]"

Code

QRegExp rx("[^0-9\\.]");
yourString.replace(rx, "");
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top