# RegExp Lookahead and split

**URL:** <https://forum.freecodecamp.org/t/regexp-lookahead-and-split/512478>\
**Category:** Curriculum Help\
**Tags:** javascript\
**Created:** [May 28, 2022, 3:43pm UTC](https://forum.freecodecamp.org/t/regexp-lookahead-and-split/512478 "2022-05-28T15:43:01Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![DevTuna-02](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/devtuna-02/32/258508_2.png) [@DevTuna-02](https://forum.freecodecamp.org/u/DevTuna-02)\
**Post date:** [May 28, 2022, 3:43pm UTC](https://forum.freecodecamp.org/t/regexp-lookahead-and-split/512478/1 "2022-05-28T15:43:01Z")

</div>

**Tell us what’s happening:**  
I want to be able to split a word after the first consonant or group of consonants(e.g if the word is freiheit, the array returned should be [fr, eiheit]), to that end I tried using a regex as an argument for a split using a lookahead like this /(?=[aeiou]\w\*)/ but cannot understand why it isn’t working. Can anyone explain me what would be the right regex to use as split argument to achieve that task?

```
  **Your code so far**

```

```js

function tear(str) {
const regex=/(?=[aeiou][a-z]*)/;
return str.split(regex);
}

console.log(tear("ccccccoonsonant"));

```

```
  **Your browser information:**

```

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

**Challenge:** Pig Latin

**Link to the challenge:**

> **[freeCodeCamp.org](https://www.freecodecamp.org/learn/javascript-algorithms-and-data-structures/intermediate-algorithm-scripting/pig-latin)**
>
> Learn to Code — For Free

---

<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:** [November 27, 2022, 3:43am UTC](https://forum.freecodecamp.org/t/regexp-lookahead-and-split/512478/2 "2022-11-27T03:43:52Z")

</div>

Closed on November 27, 2022, 3:43am UTC

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