RegExp Lookahead and split

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**

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:

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