Skip to content
JS FAQ - JavaScript Guides Online

Get answers to your JavaScript questions. Explore detailed how-to guides, code examples, and best practices for beginners and developers.

  • Home
  • Home
Books
Home » matchAll
How to extract all matches using regex in JavaScript
Posted inStandard Objects: RegExp

How to extract all matches using regex in JavaScript

Posted inStandard Objects: RegExpTags: global, js regexp, matchAll, regexp
The string.match method returns matched substrings or null, with behavior dependent on the global flag. Without 'g', it returns the first match and capturing groups. With 'g', it returns all matches without groups. For capturing groups on all matches, use RegExp.exec in a loop or matchAll with 'g'.
Read More
Copyright 2026 — JS FAQ - JavaScript Guides Online. All rights reserved.
Scroll to Top