Who can explain in detail, but simply, what fis3 means by $0,$1,$2?

  node.js, question

After reading the official documents, I still don’t quite understand what it means and forget the advice of the great god.
图片描述

After looking at the following documents, this grouping is basically the same as the regular grouping.

For example/a/foo.jsThe expression above/a/(**.js)

$0:/a/foo.js
$1:foo.js


update:

Can refer tohttps://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/RegExp

Explanation of Regular Grouping

(x)
 
 Match x and capture matches.  This is called capturing parentheses.
 
 For example, /(foo)/ matches and captures "foo" in "foo bar."  The matched substring can be found in the elements [1], ..., [n] of the result array, or in the attributes $1, ..., $9 of the defined RegExp object.

Here, $1, …, $9 is the matching content in the first, …, ninth brackets.

In brief:

$0Is all the matching content,$1Is the first parenthetical match, …$9Is the ninth bracket match