On a site I am working on I have a requirement that usernames not start with <alpha><alpha>_
So these should not be allowed:
- SU_Coolguy
- MR_Nobody
- my_Pony
But these should be ok:
- __SU_Coolguy
- MRS_Nobody
- YourPony
In the framework I am using, I am only able to validate against matching regular expression, not non-matching. So far I have come up with this:
"/^([^A-Za-z0-9]{2}\_|[A-Za-z0-9]{3,27})/"
This works for most items, but fails on “__SU_Coolguy”.
Any help on this regex would be highly appreciated. 🙂
Your regex would be
/^(?![a-zA-Z0-9]{2}_)/. It means “start with not {two alphanumeric characters and an underscore}”.