Need Feedback: Working on a regex to validate input

I’m working on a regex to validate a form field’s input. I’ve just begun to learn about regular expressions and would like to see if anyone has any feedback.

What I’m trying to do:

  • The input can contain multiple words
  • Can not contain any symbols other than white space and - (dash)
  • I don’t want the first character to be a number
  • After the first character the string can be alpha-numeric

Valid Examples:

  • My Name
  • SomeName1
  • Another-Name Folks

Invalid Examples:

  • 1or The Other
  • *Hello Dr. *Jones
  • What_is_Going on

Here’s what I came up with:

It seems to be working fine, but I’m not sure if there are any shortcuts I may be able to use, or if I’m leaving anything out.

  1. A-z ↩︎

ok, after some more testing I’ve come up with this process:

First I strip any white space from the begin and the end of the string using this regex: ^\s+|\s+$

Then I perform a validation check using this regex: [1]+[A-z0-9\s-]+[A-z0-9]$

  1. A-z ↩︎