[Javascript] Regular Exp

Hakan M (Backbase) hakan at backbase.com
Fri Jan 7 06:26:16 CST 2005


 > var number_re = /[^0-9]/g

This regexp rather matches anything BUT a number, unless I'm completely 
confused.

You could try this, it's untested but should be in the right direction.

var number_re = /[0-9]+\.[0-9]{2}/;

Regards,
H

Laurent Muchacho wrote:
> Hi Guru's
> 
> I got a regex I need but can't find any good references on regex since
> netscape brought down devedge.
> 
> What I need is a regex that match any number with 2 decimal 100.00 or 43.54
> I call a function on the event onKeyDown on my input type text and check if
> you input a number.
> I got the logic working fine but my regex only match number and I need a
> number with 2 decimal. 
> 
> this is what I got for matching only number.
> var number_re = /[^0-9]/g
> 
> I tried this to match any number and a dot but it doesn't work.
> var number_re = /[^0-9]+\./g
> 
> I hope you guy's can give me a hand on this and with shawn relaunching this
> list a few days ago I'm desperate about this regex skills he was talking
> about.
> 
> Thanks 
> _______________________________________________
> Javascript mailing list
> Javascript at LaTech.edu
> https://lists.LaTech.edu/mailman/listinfo/javascript
> 
> 



More information about the Javascript mailing list