9 chars · 1 line
8 chars · 1 line
9 chars · 1 line
8 chars · 1 line
Regex grouping behavior
The syntax (?:...) groups tokens for alternation or quantification without creating another numbered capture. In the preloaded matcher example, cats and dogs are found while the captures array stays empty. This tool is free to use. No account or payment is required.
Last updated
The ?: marker prevents the group from creating a capture slot. It does not remove the parentheses' effect on alternation, sequence, or quantifier scope.
Group cat|dog before s? without capturing the animal token.
(?:cat|dog)s? / g
cats dogscats
dogs
(no numbered captures)Common questions
The grouped matching behavior is the same; the difference is that (?:...) does not create a numbered capture.
Fewer incidental captures make indexes easier to maintain and can better communicate that the group exists only for structure.
Yes. You can apply ?, *, +, or bounded quantifiers to a non-capturing group just like an ordinary group.
Debugging a specific Regex issue? Browse Regex troubleshooting.