On Sun, Sep 18, 2011 at 4:36 PM, Sven Van Caekenberghe <sven@beta9.be> wrote:
Hi Larry,

On 18 Sep 2011, at 21:37, Larry White wrote:

> Hi,
>
> I need to convert web input (Strings) to decimal numbers. I have a regex that will recognize numeric strings, but not all of them can be converted to a number with asNumber. �For example, anything with a leading $+ fails, as does anything beginning with '.' �(even though .3 isNumber answers true.) or '-.'
>
> Is there any code for dealing with this kind of thing (ie a method to be called before calling asNumber or a more robust library for string conversions? Given that all web input is strings and a lot of it is decimal numbers, i have to believe there is code somewhere that does this safely, maybe even with tests. :)
>
> Thanks.

Maybe Number class>>#readFrom:ifFail: would be helpful ?

Sven

Thank you. When I was looking for that method, I found the class ExtendedNumberParser, which handles all the cases mentioned properly. ��