Regex for username validation in JavaScript
A typical username is 3-16 characters of letters, digits, and underscores. This anchored pattern enforces that. Adjust the length bounds with the live tester.
/^[A-Za-z0-9_]{3,16}$/Try it live
The pattern and sample strings below are pre-loaded. Edit anything, or describe a variation in plain English and generate your own.
/^[A-Za-z0-9_]{3,16}$/valid ✓Tested live on the JavaScript engine. Other flavors are validated and flagged for differences, not executed.
No samples.