ruby - Regex that expresses "at least one non-digit" -


I want to validate the user names according to this schema:

  1. acceptable characters: The first letter should be one letter or one number
  2. 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

Popular posts from this blog

oracle - The fastest way to check if some records in a database table? -

php - multilevel menu with multilevel array -

jQuery UI: Datepicker month format -