Spinal Tap Case-regular expression(positive lookahead)

Hi guy,
One of the steps I take is to match all the uppercase letter under the condition that there is one lowercase letter preceding it(This criteria is set to avoid matching the first uppercase letter of the sentence). After that I replace the matches with 'hyphen match".
In order to achieve the wanted results, I opt for “positive lookahead” to check for the lowercase letter preceding it.
However, it seems like there is something going wrong with my code.
Please take a look at the critical line of code I wrote down below.
str=str.replace(/(?=[a-z])([A-Z])/g,"-$1")
Does anyone know what renders this code wrong?

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