expect {
-re {(*\-\d\d\#$)} { break}
"invalid input" { puts "Wrong input"; exit}
}
Thanks in advance for your help.
> -re {(*\-\d\d\#$)} { break}
I suspect you meant (.*-\d\d\#$)
In an RE, "*" on its own just means "one asterisk". And unless I'm
mistaken, you don't need to escape the hyphen.
--
Jonathan Bromley, Consultant
DOULOS - Developing Design Know-how
VHDL * Verilog * SystemC * e * Perl * Tcl/Tk * Project Services
Doulos Ltd., 22 Market Place, Ringwood, BH24 1AW, UK
jonathan...@MYCOMPANY.com
http://www.MYCOMPANY.com
The contents of this message may contain personal views which
are not the views of Doulos Ltd., unless specifically stated.
> On 12 Jul 2006 08:55:40 -0700, Ray
> Muforosky <muf...@gmail.com> wrote:
>
> > -re {(*\-\d\d\#$)} { break}
>
> I suspect you meant (.*-\d\d\#$)
>
> In an RE, "*" on its own just means "one asterisk". And unless I'm
> mistaken, you don't need to escape the hyphen.
Actually * means zero to many of the preceeding atom. In this case there
isn't one and the regexp won't even compile:
% regexp {(*\-\d\d\#$)} foo-42#
couldn't compile regular expression pattern: quantifier operand invalid
Michael
>On Wed, 12 Jul 2006, Jonathan Bromley wrote:
>> In an RE, "*" on its own just means "one asterisk".
No, it doesn't...
>Actually * means zero to many of the preceeding atom.
Indeed it does. Blush. Blame old age.
At least my fix was right ;-)
What about:
-re ".*-\[0-9\]\[0-9\]#$" { ...
or even
-re "\[A-Z\]+-\[0-9\]\[0-9\]#$" { ...
second regular if only we expected upper characters like "VXUJT-12#".
But I have a question, because I noticed that you used regular like
"\d", is it mean digit ? Which version of regular is able to work with it?
Regards
Sebastian
> But I have a question, because I noticed that you used regular like
> "\d", is it mean digit ? Which version of regular is able to work with it?
>
yes it does, there are numerous shorthand escapes which are all documented
on the re_syntax man page in the ESCAPES section
http://www.tcl.tk/man/tcl8.4/TclCmd/re_syntax.htm#M28
These arrived in 8.1 if I recall correctly
Bruce
Thanks a lot for answer and link. It will check my view at re from now.
Sebastian