Hi,
After seeing Larry Virden's message I checked my previous answer. It
looks like regexp was enhanced post tcl8.0 which is what I'm still
running. Larry's test script didn't give expected results on 8.0,
but of course did on 8.2.
Just thought I'd mention this in case backward compatibility is an
issue.
Ross
On Tue, 23 Nov 1999, Ross Johnson wrote:
> 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).
>
+----------------------+---+
| 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).