# Lookahead in Regular Expression

**URL:** <https://forum.freecodecamp.org/t/lookahead-in-regular-expression/442704>\
**Category:** Curriculum Help\
**Tags:** javascript\
**Created:** [January 26, 2021, 7:57am UTC](https://forum.freecodecamp.org/t/lookahead-in-regular-expression/442704 "2021-01-26T07:57:15Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![tscrosb](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/tscrosb/32/134390_2.png) [@tscrosb](https://forum.freecodecamp.org/u/tscrosb)\
**Post date:** [January 26, 2021, 7:57am UTC](https://forum.freecodecamp.org/t/lookahead-in-regular-expression/442704/1 "2021-01-26T07:57:15Z")

</div>

**Tell us what’s happening:**  
I am having trouble with this challenge. One of the test cases is “8pass99”, and I am not sure how to make sure only two consecutive digits are matched.

**Your code so far**

```js

let sampleWord = 'astronaut';
let pwRegex = /^\D(?=\w{5})(?=\w*\d{2})/; // Change this line
let result = pwRegex.test(sampleWord);

```

**Your browser information:**

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

**Challenge:** Positive and Negative Lookahead

**Link to the challenge:**

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

---

<div class="post-metadata">

**Author:** ![moriel](https://avatars.discourse-cdn.com/v4/letter/m/7bcc69/32.png) [@moriel](https://forum.freecodecamp.org/u/moriel)\
**Post date:** [January 26, 2021, 8:43am UTC](https://forum.freecodecamp.org/t/lookahead-in-regular-expression/442704/2 "2021-01-26T08:43:39Z")

</div>

Hi,

Remove ^and check again!

---

<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:** [January 26, 2021, 10:55am UTC](https://forum.freecodecamp.org/t/lookahead-in-regular-expression/442704/3 "2021-01-26T10:55:04Z")

</div>

> [@tscrosb](#):
>
> `^\D`

you are saying that the string should not start with a number, but there is not such a limit

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/freecodecamp/original/3X/e/1/e1c433102e34b46dfaa3e15d13ab9a514b127078.svg) [@system](https://forum.freecodecamp.org/u/system)\
**Post date:** [July 27, 2021, 10:55pm UTC](https://forum.freecodecamp.org/t/lookahead-in-regular-expression/442704/4 "2021-07-27T22:55:05Z")

</div>

Closed on July 27, 2021, 10:55pm UTC

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