in reply to Re: Validating Numbers in CGI Script?
in thread Validating Numbers in CGI Script?
The look-ahead is used to remove the redundancy in your regex. It basically ensures there's either a digit, or a dot and THEN a digit. Then, it matches digits and/or a dot and digits, which we know will be valid./^(?:-)?(?:\d+(?:\.\d+)?|\.\d+)$/ # becomes /^-?(?:\d+(?:\.\d+)?|\.\d+)$/ # UPDATE! /^-?(?=\d|\.\d)\d*\.?\d+$/
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Re: Validating Numbers in CGI Script?
by dha (Acolyte) on May 11, 2001 at 03:08 UTC | |
by japhy (Canon) on May 11, 2001 at 03:51 UTC | |
|
Re (tilly) 2: Validating Numbers in CGI Script?
by tilly (Archbishop) on May 11, 2001 at 05:56 UTC | |
|
Re: Re: Re: Validating Numbers in CGI Script?
by larryk (Friar) on May 10, 2001 at 19:27 UTC | |
by lestrrat (Deacon) on May 10, 2001 at 21:50 UTC | |
by japhy (Canon) on May 10, 2001 at 19:42 UTC | |
by buckaduck (Chaplain) on May 10, 2001 at 21:24 UTC |