Unsolved how to trim or normalize a QString?
how to trim or normalize a QString? mainly remove the space and comma.
eg. " , a,b ,c, d,," to "a,b,c,d"
KroMignon last edited by
@opengpu the easiest way is:
QString noSpace = myString.split(' ', QString::SkipEmptyParts).join("");
u mean 1st replace all "," to " ", and then simplified?
and then split by " ", i will get "a" "b" "c" "d" in the QStringlist, right?
KroMignon last edited by KroMignon
mainly remove the space and comma.
Oups, I think a read/reply too quickly your question: perhaps is should be:
auto listParts = myString.split(QRegExp(" |,"), QString::SkipEmptyParts);
This will remove all spaces and coma and generate a list with the elements.
perhaps a better implementation could be
auto listParts = myString.remove(' ').split(',');
So you could get also empty elements.