1
votes

I have this working definition:

IDENTIFIER   [a-zA-Z][a-zA-Z0-9]*

I don't want to keep repeating the [a-zA-Z] and [0-9], so I made two new definitions

DIGIT    [0-9]
VALID    [a-zA-Z]

How can I rewrite the IDENTIFIER rule to use the DIGIT and VALID definitions?

I don't know how to do the "second" match, I'm stuck here:

IDENTIFIER {VALID}[{VALID}{DIGIT}]* // This syntax is incorrect

Thanks.

Edit: The entire test program that I'm using: http://pastebin.com/f5b64183f.

2

2 Answers

3
votes

It looks like you actually want:

IDENTIFIER {VALID}({VALID}|{DIGIT})*

[{VALID}{DIGIT}] resolves to [[A-Za-z][0-9]] which is not a legal construct.

-1
votes

I think this will do it, but I can't test it. Do you have sample data?

(?:[a-zA-Z])+(?:[0-9])+