๐Ÿ”ฐgroup

capturing or non-capturing groups

JS โŸฉ value โŸฉ object โŸฉ regex โŸฉ pattern โŸฉ group

(...)	        // 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

Last updated