Extract regex matches

Extract regex matches runs your own JavaScript regular expression against pasted text and lists every match using the separator you choose. Set the Pattern, the Flags (g, gi or gm), and the Separator (newline, space, comma or tab) in the settings panel. The match runs in your browser. Pair this with find and replace for literal swaps and regex replace when you need to rewrite matches.

Input
Line 1:1 LF cloud_done Saved locally
Result Extract Regex Matches
0 lines 0 chars

How regex extraction works here

The tool calls String.prototype.match(new RegExp(pattern, flags)) with the Pattern and Flags from the settings panel, then joins the matches with your chosen Separator. Anything that is valid JavaScript regex syntax is accepted: character classes, anchors, lookaheads, lookbehinds, named groups, Unicode escapes. The g flag is on for every preset because the tool needs all matches, not just the first.

Capture groups are not extracted on their own. match with the g flag returns the full match strings, not the groups. If you want a specific group, wrap the rest of the pattern in (?:...) non-capturing groups and put the part you want last. To rewrite matches into a different shape entirely, use regex replace, which respects $1, $2 and named back-references.

When the pattern is empty the tool prints a hint instead of running. When the pattern is invalid the tool catches the SyntaxError and shows the message, so you can fix the pattern without losing your input. Use this tool whenever the dedicated extract pages (emails, URLs, phones) are too narrow or too loose for your data.

How to use extract regex matches

  1. 1Paste your text into the input panel.
  2. 2Open the settings panel and type a regex into Pattern (for example \b\w+\b for words).
  3. 3Set Flags to g, gi (case-insensitive) or gm (multiline anchors).
  4. 4Set Separator to Newline, Space, Comma or Tab depending on how you want the matches joined.
  5. 5Click Copy or Download on the output panel when the result looks right.

Keyboard shortcuts

Drive TextResult without touching the mouse.

Shortcut Action
Ctrl FOpen the find & replace panel inside the input Plus
Ctrl ZUndo the last input change
Ctrl Shift ZRedo
Ctrl Shift EnterToggle fullscreen focus on the editor Plus
EscClose find & replace, or exit fullscreen
Ctrl KOpen the command palette to jump to any tool Plus
Ctrl SSave current workflow draft Plus
Ctrl PRun a saved workflow Plus

What this tool actually does

Pattern uses native JavaScript regex

Anything RegExp in your browser supports works here: character classes [a-z], anchors ^ $ \b, quantifiers, alternation, lookaheads (?=...), lookbehinds (?<=...), named groups (?<name>...), Unicode escapes \p{...} (with the u flag, which the tool accepts inside the pattern).

Flags dropdown: g, gi, gm

g matches all occurrences (always on). gi adds case-insensitive matching. gm makes ^ and $ match at line breaks instead of just the start and end of the input. To combine flags (e.g. gim), put the extras inside an inline modifier at the start of the pattern: (?i) or (?m) in browsers that support inline flags.

Separator dropdown: newline, space, comma, tab

The matches are joined with the chosen string. Newline gives one match per line (best for piping into other tools). Comma adds ", " between matches. Tab gives a TSV-friendly single line.

Empty or invalid pattern is handled

If the Pattern field is blank, the output reads [enter a pattern in the Settings panel]. If the pattern fails to compile, the output shows [invalid regex] followed by the browser's error message, so you can adjust the pattern without losing your input.

Capture groups are not extracted separately

With the g flag, JavaScript's match returns full match strings only. Capture groups are ignored. To pull just one group out, wrap the rest in (?:...) and put your wanted text outside the non-capturing groups. To rewrite matches, switch to regex replace.

Worked example

Pattern #\d+, flags g, separator newline. Change the pattern to v\d+\.\d+\.\d+ and you get v2.0.1 and v2.1.0 instead.

Input
Order #4821 ships Apr 12. Order #4822 ships Apr 13.
Contact [email protected] or [email protected].
Versions v2.0.1 and v2.1.0.
Output
#4821
#4822

Settings reference

Setting Effect on output
Pattern Any JavaScript regex. Empty pattern prints a hint; invalid pattern prints the browser's error.
Flags = g Global. Returns every match in source order.
Flags = gi Global plus case-insensitive. HELLO and hello both match hello.
Flags = gm Global plus multiline. ^ and $ match line starts and ends, not just the input boundaries.
Separator = Newline One match per line. Best for piping into other tools.
Separator = Space Matches joined by single spaces.
Separator = Comma Matches joined by , for CSV-style output.
Separator = Tab Matches joined by tabs. Drop straight into a TSV column.

FAQ

How do I extract just one capture group?
JavaScript's match with the g flag returns full match strings, not groups. Two workarounds: wrap the parts you do not want in non-capturing groups (?:...) and use lookarounds (?<=prefix)wanted(?=suffix) to anchor the match without including the prefix or suffix; or switch to regex replace, which supports $1, $2 and named back-references in the replacement.
Why is my ^ only matching at the start of the input?
Set Flags to gm. With g alone, ^ and $ match the start and end of the whole input. With gm, they match the start and end of each line.
Can I use Unicode property escapes like \p{L}?
Yes, in modern browsers. The pattern \p{L}+ with flags gu matches runs of any Unicode letter. To get the u flag in the dropdown, put it inline at the start of the pattern: (?u)\p{L}+ in browsers that support inline flags, or rely on the g flag and let the engine treat the pattern as Unicode-aware where possible.
What happens if my pattern has a syntax error?
The output panel shows [invalid regex] followed by the browser's parse error. Your input is not modified, so you can fix the pattern and try again. Common gotchas: unescaped slashes inside character classes, mismatched parentheses, and invalid back-references.
Is anything sent to a server?
No. The match runs entirely in your browser. Nothing is uploaded.