Extract regex capture groups

Inspect numbered and named capture groups for a regular expression match.

freeworks offlinenothing uploaded
ToolRegex Groups
Input
Output
Put this on your own site

The frame below runs the same code as this page, in the reader's own browser. Nothing is sent to us, and nothing is sent to you.

Pick a dark background and the text and panels follow it, so the frame stays readable on a dark page.

Preview

How it works

Capturing parentheses are indexed by opening order, named groups are collected by label, and a match records the full text plus each participating subgroup. An absent optional group produces an undefined capture.

  • Numbered groups preserve JavaScript compatibility.
  • Named groups make extracted fields readable.

Worked example

Extract year, month, day from ISO dates
Use capture groups to extract year, month, and day from a date string
Input
											Today is 2024-01-15 and tomorrow is 2024-01-16
										
Output
												Pattern: /(\w+)/g

Match 1: "Today"
  Group 1: "Today"
Match 2: "is"
  Group 1: "is"
Match 3: "2024"
  Group 1: "2024"
Match 4: "01"
  Group 1: "01"
Match 5: "15"
  Group 1: "15"
Match 6: "and"
  Group 1: "and"
Match 7: "tomorrow"
  Group 1: "tomorrow"
Match 8: "is"
  Group 1: "is"
Match 9: "2024"
  Group 1: "2024"
Match 10: "01"
  Group 1: "01"
Match 11: "16"
  Group 1: "16"
											

When to use this

Log parsing, URL extraction, and replacement templates inspect captures.

Edge cases

  • Adding a nested outer group changes later numbers.
  • An optional group can be absent.
  • A repeated capture retains only the last iteration.

References