[Qt-interest] how to extract the number from QString
Andre Somers
andre at familiesomers.nl
Fri May 21 14:39:29 CEST 2010
On 21-5-2010 14:36, Eirik Ulvik wrote:
>
> 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).
>
>
Or you get yourself aquainted with QRegExp.
André
More information about the Qt-interest-old
mailing list