Skip to main content
Skip table of contents

Regex Groups

What is Group1 and Group2 ?

Any time you use parenthesis a new capture group will be generated.

The first capture group is always the entire matched string and anything else is from adding parenthesis.

When you put part of a regex pattern inside parentheses ( ), it creates a "capture group". A capture group treats that piece of the pattern as a separate unit.

The very first capture group (group 1) will always be the entire text that matched the full regex pattern.

Any additional capture groups (group 2, group 3, etc.) come from the other sets of parentheses ( ) you included in the pattern. Each additional set of parentheses marks off a new capture group.

For example, in the regex /(abc)(123)/, there are two capture groups:

  1. The full matched text "abc123"

  2. The text "123" inside the second set of parentheses

In this example you can see the preview of the capture groups just below the Regex.


The parentheses let you pick out and separate specific parts of the original text.

For example, if the original text is "file_example_2023.txt", using parentheses in the regex pattern allows you to capture certain sections like:

  • "example"

  • "2023"

  • "file_example_2023"

Instead of just matching the entire text, the parentheses let you define and extract particular substrings that are useful to you.

The result preview up top will only include the groups if you drag them into the new pattern, as shown below with Group 2 being dragged into the Pattern Builder


JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.