[Tutor] need help with a regular expression

Kelie kf9150 at gmail.com
Sun Jun 29 03:45:24 CEST 2008


Dick Moores <rdmoores <at> gmail.com> writes:

> I'm not sure of your 5th condition. Do you mean, "A hyphen should not
> be immediately followed by a hyphen"? Could you give examples of what
> you will permit, and will not permit?

Dick, your are correct. A hyphen should not be immediately followed by a hyphen.
Actually I forgot another criteria that all letters should be uppercase. Here is
the revised criteria:

1. Starts with 0-3 underscores;
2. Followed by one letter;
3. Then followed by 0 or more letters or digits or hyphens('-'), 
4. There should not be more than one continuous hyphens;
5. The last character should be letter or digit; and
6. All letters should be uppercase.

These are some examples:

G-ANNO-SYMB is good;
-G-ANNO-SYMB is bad;
_G-ANNO-SYMB is good;
_TEMP is good;
____TEMP is bad; (4 leading underscores);
c-n-cen is bad; 
C-N-CEN is good;
C-N-BLDG1 is good;
C_N-BLDG1 is bad;
C N BLDG is bad;
1 is bad;
_1-TEXT is bad;
_TEXT-1 is good.

Thanks.





More information about the Tutor mailing list