Guide
Regex Groups and Captures
How capturing and non-capturing groups work in a regular expression.
Groups let one pattern match several parts at once and read them back. Capturing groups change the match result; non-capturing groups only group.
01Steps
- Wrap the part you want to read back in parentheses.
- Use (?: ) when you only need to group, not capture.
- Read named groups by name instead of by index.
- Check the full match and each group separately.
Named groups are clearer
A named group keeps the code readable when the pattern changes.
02Limitations
Covers ECMAScript group syntax; other engines differ and may not support every construct.
Sources
- MDN: Groups and backreferences — MDN Web Docs (accessed 2026-09-01)
Test this in your browser
The tool runs entirely in your browser; the input you use never leaves it.
About the author
Gampangin builds and maintains free, browser-based developer tools and the documentation that makes them trustworthy. The organization is accountable for every page published on this site.