# Restrict Possible Usernames Explanation

**URL:** <https://forum.freecodecamp.org/t/restrict-possible-usernames-explanation/218266>\
**Category:** Curriculum Help\
**Tags:** javascript\
**Created:** [August 16, 2018, 3:32am UTC](https://forum.freecodecamp.org/t/restrict-possible-usernames-explanation/218266 "2018-08-16T03:32:16Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Phantom](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/phantom/32/97092_2.png) [@Phantom](https://forum.freecodecamp.org/u/Phantom)\
**Post date:** [August 16, 2018, 3:32am UTC](https://forum.freecodecamp.org/t/restrict-possible-usernames-explanation/218266/1 "2018-08-16T03:32:16Z")

</div>

**Tell us what’s happening:**

Athough i passed the challenge, i don’t have the answer why this syntax " let userCheck = /\D/g; " was correct too.

**Your code so far**

```js

let username = "JackOfAllTrades";
let userCheck = /\D[0-9]*/g; // 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/68.0.3440.106 Safari/537.36`.

**Link to the challenge:**

> **[freeCodeCamp.org](https://www.freecodecamp.org/learn/javascript-algorithms-and-data-structures/regular-expressions/restrict-possible-usernames)**
>
> Learn to Code — For Free

---

<div class="post-metadata">

**Author:** ![gunhoo93](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/gunhoo93/32/87162_2.png) [@gunhoo93](https://forum.freecodecamp.org/u/gunhoo93)\
**Post date:** [August 16, 2018, 3:54am UTC](https://forum.freecodecamp.org/t/restrict-possible-usernames-explanation/218266/2 "2018-08-16T03:54:06Z")

</div>

It’s natural to feel that way for this challenge because the challenge accepts many incorrect solutions. Bottom line is that the test for this challenge doesn’t check any false positives that violate the given rule set. It doesn’t even strictly check the given rule set.

Your regex says “Match non-digit followed by zero or more digits” and check this globally.  
Now based on this, see if your regex will match the following inputs.

```auto
"a"
"1a"
"1a1"
"a1a"

```

These examples violate the rule set from the challenge. However, your regex will happily let them pass.

It is little tricky (or verbose) to get this challenge correct. You will definitely need more than what you learned. So, I’d suggest you just let this one go for now and come back when you have sufficient regex knowledge.

---

<div class="post-metadata">

**Author:** ![Phantom](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/phantom/32/97092_2.png) [@Phantom](https://forum.freecodecamp.org/u/Phantom)\
**Post date:** [August 16, 2018, 9:04am UTC](https://forum.freecodecamp.org/t/restrict-possible-usernames-explanation/218266/3 "2018-08-16T09:04:25Z")

</div>

I got it! Thanks for your help!

---

<div class="post-metadata">

**Author:** ![ILM](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/ilm/32/363239_2.png) [@ILM](https://forum.freecodecamp.org/u/ILM)\
**Post date:** [February 2, 2021, 11:35am UTC](https://forum.freecodecamp.org/t/restrict-possible-usernames-explanation/218266/4 "2021-02-02T11:35:16Z")

</div>

Closed on February 2, 2021, 11:35am UTC


