[thelist] numeric only regex?

Frank lists at frankmarion.com
Tue Aug 2 18:39:16 CDT 2005


At 12:51 PM 2005-08-02, you wrote:
>Hi, I'm trying to come up with a simple regex that will allow me to test 
>for numbers 0-9 ONLY. The
>numbers are held in a variable 'numtext'. I got as far as:
>
>var match = /[\d\d]/.test(numtext);

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]?

Here's  a pretty useful reference

http://www.anybrowser.org/bbedit/grep.shtml







Frank Marion     lists at frankmarion.com      Keep the signal high.




-- 
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.338 / Virus Database: 267.9.7/60 - Release Date: 2005-07-28




More information about the thelist mailing list