Use regex to allow for alphabetic characters, hypens, underscores, spaces, and numbers

Viewed 4488

I would like to validate using Laravel for a unique situation. The field I am authorizing is the name of a book. So it can have alphabetic characters, numeric characters, spaces, and hypens/underscores/any other key. The only thing I don't want it to have is spaces at the beginning, before you enter any key. So the name can't be " L", notice the space, whereas "L L L" is completely acceptable. Could anyone help me in this situation?

So far I got a regex validation as such:

regex:[a-z{1}[A-Z]{1}[0-9]{1}]

I'm unsure how to include the other restrictions.

2 Answers
Related