2.6 KiB
		
	
	
	
	
	
	
	
			
		
		
	
	id, title, challengeType, forumTopicId, dashedName
| id | title | challengeType | forumTopicId | dashedName | 
|---|---|---|---|---|
| 587d7db8367417b2b2512ba2 | Restrict Possible Usernames | 1 | 301363 | restrict-possible-usernames | 
--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.
- 
Usernames can only use alpha-numeric characters.
 - 
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.
 - 
Username letters can be lowercase and uppercase.
 - 
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.
--hints--
Your regex should match the string JACK
userCheck.lastIndex = 0;
assert(userCheck.test('JACK'));
Your regex should not match the string J
userCheck.lastIndex = 0;
assert(!userCheck.test('J'));
Your regex should match the string Jo
userCheck.lastIndex = 0;
assert(userCheck.test('Jo'));
Your regex should match the string Oceans11
userCheck.lastIndex = 0;
assert(userCheck.test('Oceans11'));
Your regex should match the string RegexGuru
userCheck.lastIndex = 0;
assert(userCheck.test('RegexGuru'));
Your regex should not match the string 007
userCheck.lastIndex = 0;
assert(!userCheck.test('007'));
Your regex should not match the string 9
userCheck.lastIndex = 0;
assert(!userCheck.test('9'));
Your regex should not match the string A1
userCheck.lastIndex = 0;
assert(!userCheck.test('A1'));
Your regex should not match the string BadUs3rnam3
userCheck.lastIndex = 0;
assert(!userCheck.test('BadUs3rnam3'));
Your regex should match the string Z97
userCheck.lastIndex = 0;
assert(userCheck.test('Z97'));
Your regex should not match the string c57bT3
userCheck.lastIndex = 0;
assert(!userCheck.test('c57bT3'));
Your regex should match the string AB1
userCheck.lastIndex = 0;
assert(userCheck.test('AB1'));
Your regex should not match the string J%4
userCheck.lastIndex = 0;
assert(!userCheck.test('J%4'))
--seed--
--seed-contents--
let username = "JackOfAllTrades";
let userCheck = /change/; // Change this line
let result = userCheck.test(username);
--solutions--
let username = "JackOfAllTrades";
const userCheck = /^[a-z]([0-9]{2,}|[a-z]+\d*)$/i;
let result = userCheck.test(username);