Regex challenge conditions not met

Tell us what’s happening:
This regex matches all the conditions mentioned in the challenge except for these two:

  1. Your regex should not match the string BadUs3rnam3
  2. Your regex should not match the string J%4
    Can these two conditions be met without changing the regex I have written so far? If so, please tell what needs to be added to meet the conditions.

Your code so far

let username = "JackOfAllTrades";
let userCheck = /^\w\D|^[A-Z]\d\d/; // Change this line
let result = userCheck.test(username);

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/102.0.5005.115 Safari/537.36

Challenge: Restrict Possible Usernames

Link to the challenge:

you should use {min,} operator for least number of characters for example if you want at least two characters {2,} and also use $ for digits to be in the end

The regex matches all the strings that:

  1. begins with the one “word character” followed by one “non digit character”
    or
  2. begins with one “letter” followed by 2 digits.

This regex doesn’t satisfy any of the task requirements.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.