ToolFactory

Regex Match Extractor

Extract all matches from a text using a regular expression and specified flags.

How the Regex Match Extractor works

Enter your regular expression into the "Regular expression" field. This is the pattern you want to match.

Input any flags you need into the "Flags (g, i, m...)" field. Common flags include 'g' for global matching, 'i' for case-insensitive matching, and 'm' for multi-line matching. If you do not specify 'g', the tool will only find the first match.

Type or paste the text you want to search into the "Test text" area. The tool will then process the text using your regular expression and flags. It will display the total number of matches found and list each extracted match.

Formula used

pattern compiled with your flags, then matched against the test text

SymbolMeaning
patternthe regular expression body, without slashes
flagsg, i, m, s, u or y
test textthe input to match against

The pattern is compiled by the browser’s own engine, so the result matches what JavaScript will do in your code. An invalid pattern returns the engine’s exact error message instead of failing silently.

Inputs used: Regular expression, Flags (g, i, m...), Test text.

Worked example

Let's extract all numbers from a date string using the default settings.

Result:

Frequently asked questions

What is a regex match extractor?
A regex match extractor identifies and lists all substrings within a larger text that conform to a specified regular expression pattern.
How do I use regex flags?
Regex flags modify the behavior of the regular expression search. Common flags like 'g' (global) find all matches, 'i' (insensitive) ignores case, and 'm' (multiline) treats each line separately.
Can I extract multiple matches with regex?
Yes, to extract multiple matches, you typically need to include the 'g' (global) flag in your regular expression. Without it, most regex engines stop after the first match.
What is the difference between \d and \d+?
\d matches a single digit. \d+ matches one or more digits in a sequence, allowing you to capture multi-digit numbers.
What formula does the Regex Match Extractor use?
It uses pattern compiled with your flags, then matched against the test text, where pattern is the the regular expression body, without slashes; flags is the g, i, m, s, u or y; test text is the the input to match against.
How do I read the result?
The pattern is compiled by the browser’s own engine, so the result matches what JavaScript will do in your code. An invalid pattern returns the engine’s exact error message instead of failing silently.