> For the complete documentation index, see [llms.txt](https://lochiwei.gitbook.io/web/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://lochiwei.gitbook.io/web/js/val/builtin/regex/pattern/group.md).

# group

capturing or non-capturing groups

[JS](/web/js.md) ⟩ [value](/web/js/val.md) ⟩ [object](/web/js/val/obj.md) ⟩ [regex](/web/js/val/builtin/regex.md) ⟩ [pattern](/web/js/val/builtin/regex/pattern.md) ⟩ group

{% hint style="success" %}

```javascript
(...)	        // unnamed capturing group
(?<name>...)	// named capturing group
(?:...)	        // non-capturing group
(...|...|...)	// alternation

\N	        // match the text in unnamed capture #N.
\<name>	        // match the text in named capture “name”.

//                      ╭─#1──╮   ╭╮ <--- same as capture #1
const regex = /(?:\d{2})(\d{3})\d+\1/;
//             ╰───────╯ non-capturing group
//   ╭1╮    ╭1╮
   001234004123567
// ╰───match───╯
// ╰╯ non-capturing group
```

{% endhint %}

{% tabs %}
{% tab title="🔴 主題" %}

* [capturing group](/web/js/val/builtin/regex/pattern/group/capturing-group.md)
  * [named group](/web/js/val/builtin/regex/pattern/group/capturing-group/named-group.md)
    {% endtab %}

{% tab title="💈範例" %}

* [parse .ini file](/web/js/val/builtin/regex/ex/parse-.ini-file.md) - named group
* [quick brown fox](/web/js/val/builtin/regex/ex/quick-brown-fox.md) - named group
  {% endtab %}

{% tab title="📗 參考" %}

* [ ] JS.info ⟩ [Capturing groups](https://javascript.info/regexp-groups)
* [ ] [Regular Expression Quick Reference](http://regexrenamer.sourceforge.net/help/regex_quickref.html)
  {% endtab %}
  {% endtabs %}
