On Mon, 22 Nov 1999, [EMAIL PROTECTED] wrote:

> Greetings,
> 
> I seem to be having a bit of trouble getting regexp to correctly validate an
> input number for me that is not to exceed 6 whole digits and 2 decimals.
> 
> I am trying:
> 
> regexp {[0-9][0-9]{0,5}(\.[0-9][0-9]} $cost

Hi,

Tcl regexps don't recognise {m,n} AFAIK. Also, if it did work you
would also want to include ^ at the start and $ at the end of your
RE to be specific.

You may need to do something like:

if {[regexp {^([0-9]*)\.([0-9][0-9])$} $cost junk dollars cents] == 0 \
    || [string length $dollars] > 6} {
  # Illegal input

  ...

}


Ross

+----------------------+---+
| Ross Johnson         |   | E-Mail: [EMAIL PROTECTED]
| Info Sciences and Eng|___|
| University of Canberra   | FAX:    +61 6 2015227
| PO Box 1                 |
| Belconnen  ACT    2616   | WWW:    http://willow.canberra.edu.au/~rpj/
| AUSTRALIA                |
+--------------------------+


---------------------------------------------------------------------------
To unsubscribe from the Visual Tcl mailing list, please send a message
to [EMAIL PROTECTED] with "unsubscribe vtcl [EMAIL PROTECTED]" in the
message body (where [EMAIL PROTECTED] is your e-mail address).

Reply via email to