[thelist] numeric only regex?

Tom Dell'Aringa pixelmech at yahoo.com
Tue Aug 2 15:52:58 CDT 2005


--- Frank <lists at frankmarion.com> wrote:
> >Tom said:::
> >Hi, I'm trying to come up with a simple regex that will allow me to test 
> >for numbers 0-9 ONLY. 

> Depending on the language... try this:
> 
> Assuming you want only one instance of 0 to 9:     [0-9]
> Only two instances:     [0-9][0-9] OR [0-9]{2,}
> Infinite instances:     [0-9]+
> Zero or more instances:     [0-9]*
> Zero or one instances:     [0-9]?

I should have said, this is JavaScript. Based on the above, and I was trying something similar, I
have this:

var ff = RegExp("[0-9]*").test(numtext.value)
alert(ff)

But it's not right, I get true every time. We need to exclude alpha characters and special
characters (like the *). My guess is my syntax is not quite right?

Tom


http://www.pixelmech.com/

Melissa: Ace, Where are you?
Ace Ventura: I'm in Psychoville and Finkle's the Mayor.



More information about the thelist mailing list