A function that tells you whether a RegExp contains capturing groups or not.
All features up to ES2025 are supported.
npm install regexp-is-capturingimport isCapturing from 'regexp-is-capturing';
// Let's check if some regexes contain capturing groups or not
isCapturing ( /foo/ ); // => false
isCapturing ( /(foo)/ ); // => true
isCapturing ( /(?<foo>bar)/ ); // => true
isCapturing ( /(?:foo)/ ); // => falseMIT © Fabio Spampinato