Needs help with a regular expression
For many hours now I tried to construct a regular exprsession to verify that a string:
Is divided in substrings of maximum 8 characters (qualifiers) separated by a dot '.'
All first characters of a qualifier should be alphabetic the others alphanumeric
The first qualifier can not contain '*' or '%'
The remainig qualifiers may contain '*' and '%'
Any help would be greatly appreciated.
"Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
~ Terry Pratchett in Nation
Something like this can give ideas...
Of course tests can be improved. For example alphabetic characters can be defined as [^\W\d*%]+ (which is alphanumeric without * and %).
if (8<a.length) return '\n'+a+' to long substring';
if (!(/^[A-Za-z]/.test(a))) return '\n'+a+' incorrect first character';
return '\n'+a' ok !';
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)