I have a question about the Spinal Tap Case challenge.
The solution says to insert a blank before upper case letters like this:
str = str.replace(/([a-z])([A-Z])/g, '$1 $2');
I try to understand how this works, but I just don’t get it. What does $ do? Why the 1 and 2 in $1 and $2? Which part is the space to be inserted, is it the one between $1 and $2? How does regexp know to insert it before [A-Z]? Shouldn’t the [A-Z] be preceded by ?= to mean lookbehind?
And what is the name of that $ operator? Googling isn’t being helpful even though I’ve searched for three hours.
Thanks for your help.