Question

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.

Was it helpful?

Solution

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.

OTHER TIPS

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

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top