Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

105
Views
How to match a vowel in the beginning of word Regex

function translatePigLatin(str) {
    let regExp = /^[aieou]/;
    let output = str.match(regExp);
    return output;
}

console.log(translatePigLatin("california"));

I want to match a vowel in the beginning of the word implementing regex. I search but I don't find a serious result. I want to search on word if begin with consonnant or consonant cluster, and return true. Else, return false.

My code:

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You just have to negate the result to achieve the result

function translatePigLatin(str) {
  let regExp = /^[aieou]/;
  let output = str.match(regExp);
  return !output;
}

console.log(translatePigLatin("california"));
console.log(translatePigLatin("alifornia"));

You can easily achieve return the boolean value using RegExp

function translatePigLatin(str) {
  return !new RegExp("^[aeiou]").test(str);
}

console.log(translatePigLatin("california"));
console.log(translatePigLatin("alifornia"));

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!