I'm not fully sure how to word my question, so sorry for the rough title.
I am trying to create a pattern that can identify variable names with the following restraints:
- Must begin with a letter
- First letter may be followed by any combination of letters, numbers, and hyphens
- First letter may be followed with nothing
- The variable name must not be entirely X's ([xX]+ is a seperate identifier in this grammar)
So for example, these would all be valid:
- Avariable123
- Bee-keeper
- Y
- E-3
But the following would not be valid:
- XXXX
- X
- 3variable
- 5
I am able to meet the first three requirements with my current identifier, but I am really struggling to change it so that it doesn't pick up variables that are entirely the letter X.
Here is what I have so far: [a-z][a-z0-9\-]* {return (NAME);}
Can anyone suggest a way of editing this to avoid variables that are made up of just the letter X?