Skip to content

Instantly share code, notes, and snippets.

@mmack
Created October 26, 2011 09:22
Show Gist options
  • Select an option

  • Save mmack/1315863 to your computer and use it in GitHub Desktop.

Select an option

Save mmack/1315863 to your computer and use it in GitHub Desktop.
ruby regex
ruby-1.9.2-p290 :059 > u = "validusername"
=> "validusername"
ruby-1.9.2-p290 :060 > u !~ /^[a-z0-9\-_]$/
=> true
ruby-1.9.2-p290 :061 > u = "not a valid.username"
=> "not a valid.username"
ruby-1.9.2-p290 :062 > u !~ /^[a-z0-9\-_]$/
=> true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment