Regex to validate string having only lower case, first char must be a letter

regex, ruby, string

Solution

Why don't you just stick to your requirements ?

- first char must be a lowercase letter: `[a-z]`

- remaining characters must match: `[a-z0-9_.]`

-> your regex: `/^[a-z][a-z0-9_.]*$/`

Problem

I want to use the Regex to validate the string containing - must contain only lower case letters - first char must be a letter. - remaining characters must match regex `[a-z0-9_.]` I use the `/^[\w\s\-.]*$/` to validate the string. But it allows the first character like (._)

Original source