On 2010-11-16, at 09:29, André Bargull wrote:

>> static var PercentPattern = new 
>> RegExp("^\\s*(1?\\d?\\d?\\.?\\d*)\\s*%\\s*$");
>> static var NumberPattern = new RegExp("^\\s*(\\d{0,3}\\.?\\d*)\\s*$");
> 
> These patterns actually accept any number, because of the \\d*. And the 
> percent pattern also accept this string ".%" or simply "%".
> 
> Percent pattern: ^\\s*(100(?:\\.0*)?|\\d{1,2}(?:\\.\\d*)?|\\.\\d+)\\s*%\\s*$
> 1) "100", possibly followed by "." and any number of "0".
> 2) Any number in range [0,99], possibly followed by "." and any number of 
> "0". (This part allows leading "0", is that ok? For example "01%")
> 3) Or numbers without leading digits as in ".5%"
> 
> A similar for the number pattern: ^\\s*(\\d{1,3}(?:\\.\\d*)?|\\.\\d+)\\s*$

Thanks.  I rushed this out so Fred could proceed.  Clearly it needs more work.

I don't know how rigorous we really have to be on the pattern.  We could just 
allow any number of digits before/after an optional `.` and then test the 
output of parseFloat not being NaN.

If we were using parseInt, a leading 0 could be a problem due to some runtimes 
parsing that as octal.

Reply via email to