ruby - Regex that expresses "at least one non-digit" -
I want to validate the user names according to this schema:
- acceptable characters: The first letter should be one letter or one number
- User name can not be all numbers
This regular expression 1 and 2 , But I can not understand how to satisfy 3:
/ ^ [a-zA-z \ d] [\ w \ -] + $ /
(I'm using Ruby if it's relevant)
Not very efficient, but simple:
/ ^ (?! \ D + $ ) [A-zA-Z \ d] [\ w \ -] + $ /
The lookhead means the only meaning: "The number of running numbers Not a string ".
Comments
Post a Comment