SHARE
TWEET

RegEx for allowing alphanumeric at the starting and hyphen thereafter

a guest Feb 26th, 2012 26 Never
  1. a
  2.        
  3. ^[a-zA-Z0-9][a-zA-Z0-9-]*[a-zA-Z0-9]$
  4.        
  5. ^[[:alnum:]](?:[[:alnum:]-](?!-$))*$
  6.        
  7. ^(?:[[:alnum:]]+(?:-(?!$))?)+$
  8.        
  9. ^(?:[a-zA-Z0-9]+(?:-(?!$))?)+$
  10.        
  11. ^[a-zA-Z0-9]([a-zA-Z0-9-]*[a-zA-Z0-9])?$
RAW Paste Data
Top