Skip to content

Instantly share code, notes, and snippets.

@nickihastings
Created October 10, 2019 10:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nickihastings/35ea76516452d5c98d165711a70a093a to your computer and use it in GitHub Desktop.
Save nickihastings/35ea76516452d5c98d165711a70a093a to your computer and use it in GitHub Desktop.
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) The only numbers in the username have to be at the end. There can be zero or more of them at the end. 2) Username letters can be lowercase and uppercase. 3) Usernames have to be at least two characters long. A …
let username = "JackOfAllTrades";
let userCheck = /^[a-z][a-z]+\d*$/i; // Change this line
let result = userCheck.test(username);
// Your regex should match JACK
// Your regex should not match J
// Your regex should match Oceans11
// Your regex should match RegexGuru
// Your regex should not match 007
// Your regex should not match 9
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment