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

199
Views
split function is not working with the regex provided

this is my take on the problem. i have successfully passed 3/4. the only thing messing up my solution is that extra white space after ‘telebubbles’. how do i progress further? i’m not good with replace.

function spinalCase(str) {
let k=str.split(/[\s-_]?(?=[A-Z])/g).join('-').toLowerCase()
console.log(k)
return k
}

spinalCase('This Is Spinal Tap');//passed
spinalCase("thisIsSpinalTap")//passed
spinalCase("The_Andy_Griffith_Show")//passed
spinalCase("Teletubbies say Eh-oh")//not working
spinalCase("AllThe-small Things")//passed

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

0

You may use this regex to fix your problem:

/\s+|[-_]*(?=[A-Z])/

Code:

function spinalCase(str) {
    let k = str.split(/\s+|[-_]*(?=[A-Z])/g).join('-').toLowerCase();
    console.log(k);
    return k;
}

spinalCase('This Is Spinal Tap'); //passed
spinalCase("thisIsSpinalTap"); //passed
spinalCase("The_Andy_Griffith_Show"); //passed
spinalCase("Teletubbies say Eh-oh"); //passed
spinalCase("AllThe-small Things"); //passed

RegEx Details:

  • \s+: Match 1+ whitespaces
  • |: OR
  • [-_]*(?=[A-Z]): Match 0 or more of underscore or hyphen if that followed by an uppercase letter
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!