W3C home > Mailing lists > Public > whatwg@whatwg.org > December 2006

[whatwg] finding a number...

From: Mikko Rantalainen <mikko.rantalainen@peda.net>
Date: Wed, 13 Dec 2006 16:13:10 +0200
Message-ID: <45800A76.6060006@peda.net>
Charles McCathieNevile wrote:
> On Wed, 13 Dec 2006 13:17:14 +0530, Henri Sivonen <hsivonen at iki.fi> wrote:
>> On Dec 13, 2006, at 08:32, Charles McCathieNevile wrote:
>>> possible *and no simpler* - this is too simple. Maybe assuming you can  
>>> parse numbers out of text is just a dumb idea as a normative part of a  
>>> spec.
>> The attributes always work for any language. For English, the  
>> textContent works as a *bonus*. It isn't that the spec fails to work for  
>> non-English. It is just that a particular *redundant* bonus feature  
>> doesn't work for non-English.
> The problem with this is that it means copying code the natural way  
> doesn't work for some non-english speakers, and they have to read the spec  
> or guess why. [...]

I think that "they have to read the spec" is a bonus, too.

Perhaps the parser could be specified as follows:

regexp for "numeric value" is [0-9 ,.]
scan the numeric value backwards from end
first character matching regexp [,.] is the decimal separator

This would correctly interpret numbers such as

23 236 435 123,121

It would fail for numbers such as


but that such formats used in any locale?

Received on Wednesday, 13 December 2006 06:13:10 UTC

This archive was generated by hypermail 2.4.0 : Wednesday, 22 January 2020 16:58:51 UTC