I have come across a piece of code in JScript:
RegExp.$1
Does anybody know what it does?
If I output it on its own, I get nothing not e
$1 is whatever is matched in the first capture. If you have more captures you can use $2, $3 etc.
$1
$2
$3
Ex:
"abc".replace(/(.)/, "$1$1"); // aabc "abc".replace(/(.{2})/, "$1$1"); // ababc "abc".replace(/(.)(.)/, "$2$1"); // bac