Tell us what’s happening:
I am using the source:
and tried to make a code that did follow the requirments
yer can’t’ figure it out
Your code so far
let username = "JackOfAllTrades";
let userCheck = [a-z]/d/g; // Change this line
let result = userCheck.test(username);
Your browser information:
User Agent is:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_2) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.4 Safari/605.1.15.
Challenge: Restrict Possible Usernames
Link to the challenge:
a regex includes the pattern inside
/, and after that there are the flags
so you should write
is there something missing in your code?
Matches any digit is
/d if that is what you wanted (Character classes).
When defining a regular expression, you need to start with a forward slash. You indicate the end of the regex also with a
/. After which, you define your parameters (eg.
const reg = /password/g;
If you are wanting to make use of a character class, you need to escape literal strings using a backslash.
const reg = /string\d/gi;
The above will be interpreted in the following way:
/ Opens a regular expression
string is interpreted as literally “string”
\ escapes literal strings
d is interpreted as any numeric digit
/ indicates the end of the expression
g is a flag that indicates the declared expression is to be used globally
i is a flag that indicates the declared expression is case insensitive.
I hope that makes sense.
Thanks for the fast reply all i was able to solve it <3