I can’t see how it does this? When I omit the \1+, so that the expression becomes
var R = /[^]/g
It matches every individual character in a string. I understand that the caret ^ in square brackets ([^]) means “not the following”? How does this regex work exactly and how is it matching every character?
Select the ECMAScript flavor and paste the pattern without the delimiters/switches, then in the string section, the string with no quotes. Read the explanation in the top right, and the matches below that.
The above has your pattern already saved so you shouldn’t have to do anything but read the explanation.