[Qt-interest] how to extract the number from QString
Eirik Ulvik
eiriku at simsurgery.com
Fri May 21 14:36:53 CEST 2010
Den 21.05.2010 14:33, skrev hakiim the dream:
> Hi all, suppose that I have the string abc001. I have to seperate the
> characters from the numeric part so that I have abc and 001 seperated?
> Using QString::toInt() does not help to discriminate between a zero
> number and an alpha character since it returns both 0 for the alpha
> character and the integer 0.
> Thanks in advance.
>
You can iterate over all characters in the string and use
QChar::isNumber (http://doc.qt.nokia.com/4.6/qchar.html#isNumber).
Regards,
Eirik
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 551 bytes
Desc: OpenPGP digital signature
Url : http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20100521/528fd024/attachment.bin
More information about the Qt-interest-old
mailing list