I am trying to create a regex pattern for name validation. Application name must have the following:
- Lowercase alphanumeric characters can be specified
- Name must start with an alphabetic character and can end with alphanumeric character
- Hyphen '-' is allowed but not as the first or last character e.g abc123, abc, abcd-1232
This is what I got [^\[a-z\]+(\[a-z0-9\-\])*\[a-z0-9\]$][1] it doesn't work perfectly. The validation fails if you enter a single character in the field. How can I improve this pattern? Thank you in advance.