Mail Archives: djgpp/1995/02/18/01:37:41
On Fri, 17 Feb 1995, Bryan Russell wrote:
> and the rule was really [A-Z][A-Za-z0-9-_] which is supposed to read as
> Starting letter of A to Z, the rest of the leters consisting of A to Z or a to
> z or - or _. I now know why the resulting script compiler didn't work as the
> first line of the test source script had a '-' in it.
>
> Is there some sort of special delimiter to include '-' in the rule or should
> the context sort it out?
I am sure you have this figured out by now, but let me quote from "UNIX
Programmer's Manual", Vol. 5, "Languages and Support Tools", (AT&T,
1986), Lexical Analyzer Generator (LEX), p. 522 (LEX Regular Expressions,
Character Classes):
"Within square brackets, most operator meanings are ignored. Only three
characters are special; these are \, -, and ^. The - character indicates
ranges. For example
[a-z0-9<>_]
indicates the character class containing all the lowercase letters, the
digits, the angle brckets, and underline. Ranges may be given in either
order. Using - between any pair of characters which are not both
uppercase letters, both lowercase letters, or both digits is
implementation dependent and gets a warning message... If it is desired
to include the character - in a character class, it should be first or
last; thus:
[-+0=9]
matches all the digits and the two signs."
I hope this clears up your problem. As an aside, anytime you see
"implemntation dependent", assume it will result in an error!
Bill Davidson
bdavidson AT ra DOT isisnet DOT com
- Raw text -