[Javascript] Regular Exp

Laurent Muchacho LaurentM at london.virgin.net
Fri Jan 7 08:57:29 CST 2005


Hi Hakan,

Thanks a lot for this help this work much better. I'll try and have to make
it work before going in holiday tonight then I might do an ugly if else
statement anyway and will try to make it work later.

Thanks Laurent

-----Original Message-----
From: Hakan M (Backbase) [mailto:hakan at backbase.com]
Sent: 07 January 2005 14:47
To: [JavaScript List]
Subject: Re: [Javascript] Regular Exp


Laurent,

I'm a bit stressed at work now so this might be getting ugly, but you 
could try this change. It should accept one or more numbers, one or no 
dot and then zero to two digits. Hardcore regexp ninjas might see that 
this probably also accepts 1000000000000000000000000000.33 but it's as 
good as I can get it right now.

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

Regards,
H

Laurent Muchacho wrote:
> hi Hakan,
> 
> yes you right it match anything but number. Thanks this do put me in the
> right direction but it seems a bit more complicated then I expected
because
> I'm checking the value on each onKeyUp event. It mean that when you start
> typing eg: 1 for 100.55 it return false until you got the whole number.
> 
> Thanks for getting back so quick and for the help provided.
> 
> Regards
> 
> Laurent
> 
> -----Original Message-----
> From: Hakan M (Backbase) [mailto:hakan at backbase.com]
> Sent: 07 January 2005 12:26
> To: [JavaScript List]
> Subject: Re: [Javascript] Regular Exp
> 
> 
>  > 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
>>
>>
> 
> _______________________________________________
> Javascript mailing list
> Javascript at LaTech.edu
> https://lists.LaTech.edu/mailman/listinfo/javascript
> _______________________________________________
> Javascript mailing list
> Javascript at LaTech.edu
> https://lists.LaTech.edu/mailman/listinfo/javascript
> 
> 
_______________________________________________
Javascript mailing list
Javascript at LaTech.edu
https://lists.LaTech.edu/mailman/listinfo/javascript



More information about the Javascript mailing list