How to match usernames?

Just like slugs, you usually want to restrict what people can choose for their username. This will prevent future layout issues, querying problems, and who knows what else.

Simple Usernames

This will restrict a username to alphanumeric characters, underscores, and dashes. It will also force the username to be between 3-16 characters.

Regex: ^[a-zA-Z0-9_-]{3,16}$



×

Subscribe

The latest tutorials sent straight to your inbox.