--- id: 587d7db8367417b2b2512ba2 title: Restrict Possible Usernames challengeType: 1 --- ## Description
Usernames are used everywhere on the internet. They are what give users a unique identity on their favorite sites. You need to check all the usernames in a database. Here are some simple rules that users have to follow when creating their username. 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. 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.
## Instructions
Change the regex userCheck to fit the constraints listed above.
## Tests
```yml tests: - text: Your regex should match JACK testString: assert(userCheck.test("JACK")); - text: Your regex should not match J testString: assert(!userCheck.test("J")); - text: Your regex should match Jo testString: assert(userCheck.test("Jo")); - text: Your regex should match Oceans11 testString: assert(userCheck.test("Oceans11")); - text: Your regex should match RegexGuru testString: assert(userCheck.test("RegexGuru")); - text: Your regex should not match 007 testString: assert(!userCheck.test("007")); - text: Your regex should not match 9 testString: assert(!userCheck.test("9")); - text: Your regex should not match A1 testString: assert(!userCheck.test("A1")); - text: Your regex should not match BadUs3rnam3 testString: assert(!userCheck.test("BadUs3rnam3")); - text: Your regex should match Z97 testString: assert(userCheck.test("Z97")); ```
## Challenge Seed
```js let username = "JackOfAllTrades"; let userCheck = /change/; // Change this line let result = userCheck.test(username); ```
## Solution
```js let username = "JackOfAllTrades"; const userCheck = /^[a-z]([0-9]{2,}|[a-z]+\d*)$/i; let result = userCheck.test(username); ```