What does RegExp.$1 do

后端 未结 6 956
温柔的废话
温柔的废话 2021-02-02 13:34

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

6条回答
  •  感动是毒
    2021-02-02 13:59

    Like stated earlier, these constructs are called capturing parentheses groups and they're primarily used to reference the matches saved/remembered following the successful execution of an RegExp related operation.

    Also, like stated earlier, I don't advise using any of them in your code unless a well controlled environment/context is secured, like the one provided by the native replace() method found on the String.prototype object.

提交回复
热议问题