Implement a Spinal Case Converter - Implement a Spinal Case Converter

Tell us what’s happening:

I am having trouble to search online about naming a capturing group that could be a lookbehind.

For exemple, in “AllThis” i want to capture the last l of All to be a groupe and the T of This to be on another one. This way i can have somekind of replaceAll(regex, “$-$”). note : $< min> - $< maj> (the <> disapeared)

Can anybody help out ! Thanks for your time !

Your code so far

function spinalCase(str){
  let reg = /\s|_|(?<min><=[a-z])[A-Z]/g
  let string = str
  let lower = string.replaceAll(reg, "-");
  let result = lower.toLowerCase();
  return result
}

console.log(spinalCase("This Is aSpinal Tap"))

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:149.0) Gecko/20100101 Firefox/149.0

Challenge Information:

Implement a Spinal Case Converter - Implement a Spinal Case Converter

It might be not possible to have named group directly for lookbehind. Additionally, lookbehind by itself would not capture. The pattern from lookbehind would need to be wrapped with capturing group, which could be named there.