Explain this regrex?

Tell us what’s happening:
who can explain this regrex for me, please: /^[^aeiou]+/

Your code so far


function translatePigLatin(str) {
let consonantRegex = /^[^aeiou]+/;
let myConsonants = str.match(consonantRegex);
console.log(str.match(consonantRegex))
console.log(str.replace(consonantRegex, "").concat(myConsonants))
return myConsonants !== null
  ? str
    .replace(consonantRegex, "")
    .concat(myConsonants)
    .concat("ay")
  : str.concat("way");

}

translatePigLatin("california");

Your browser information:

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

Challenge: Pig Latin

Link to the challenge:

this is the explanation from a regex tool - do you have other questions on it?


I’ve edited your post. If you post a full passing solution to a challenge and have questions about it, please surround it with [spoiler] and [/spoiler] tags on the line above and below your solution code.

1 Like

I am a beginner so i have mistakes, thank you for your help.