Replace and Remove from html string not working
-
I'm receiving html from a QJsonObject, but am having trouble formatting it well enough to be able to parse it.
The html is quite long, so here's the beginning:
<div class=\"iconset_wrapper\">\r\n
The html is located in
jsonArray[6]
which I then use.toString()
on.I'd like to be able to parse it, but because of the escaped double quotes and the \r\n, I am unable to. I have confirmed that removing both problems allow my html to be parsed. To try and fix the problem, I came out with this:
QString newHtml = jsonArray[6].toString().replace("\\\"", "\"").remove("\\r\\n");
For some reason, however, the output is exactly the same (Have a print before and after).
Is there something I'm missing? I'm doing the exact same thing a few lines above and it works just fine, what happened? -
@RekTekk249 said in Replace and Remove from html string not working:
For some reason, however, the output is exactly the same (Have a print before and after).
replace()
andremove()
are working fine. Notice that your\r\n
have disappeared.Are you printing through
qDebug()
? By default,qDebug()
wraps strings with quotation marks ("
). So if the string contains"
characters, they will be escaped and printed as\"
.To view your actual text, display it in a QLabel or use
qDebug().noquote() << newHtml;