Regular Expressions 101

Community Patterns

Username (freecodecamp)

0

Regular Expression
ECMAScript (JavaScript)

/
(^(([A-Za-z])+){2,}(([0-9])+)?$)|^[A-Za-z]{2}$|(^(([A-Za-z])+){1,}((([0-9])+){2,})$)
/
gm

Description

  1. Usernames can only use alpha-numeric characters.

  2. The only numbers in the username have to be at the end. There can be zero or more of them at the end. Username cannot start with the number.

  3. Username letters can be lowercase and uppercase.

  4. Usernames have to be at least two characters long. A two-character username can only use alphabet letters as characters.

Submitted by Mathivanan - 4 years ago