Extract Regex Matches
๐ Extract every regex match from any string โ see all matches, capture groups, index positions, unique values and export in JSON, CSV or plain text.
Common Pattern Presets โ Click to Load
Regex Pattern
Tip: g flag is applied automatically for extraction. Press Enter to extract.
Input String
0 chars ยท 1 linesEnter a pattern and string, then click Extract
Use a preset above to get started instantly
Need to Replace Matches Too?
Once you have identified your pattern here, use our Regex Find and Replace tool to substitute those matches with new text โ with capture group references, multi-rule mode, line diff view and 20+ presets.
What Is Regex Match Extraction?
Regex match extraction is the process of applying a regular expression pattern to a string and collecting every substring that matches. Unlike a simple search that tells you whether something exists, extraction gives you what matched โ the actual values, their positions, and any sub-parts captured by groups inside the pattern.
This is one of the most common tasks in text processing, data wrangling, log analysis and web scraping. You might use it to pull every email address from a dump of user data, extract all phone numbers from a document, collect every URL mentioned in a log file, or find all date strings in a large block of text.
Common Use Cases
Data Cleaning & ETL
Extract structured values from messy data before importing into a database, spreadsheet or analytics tool.
Log File Analysis
Pull error codes, timestamps, IP addresses or specific patterns from server logs and application logs.
Web Scraping
Extract links, prices, product codes, dates or any pattern from HTML or raw text content.
Security Auditing
Find API keys, tokens, passwords or sensitive patterns accidentally committed to code or config files.
Content Processing
Extract mentions, hashtags, references or citations from social media content, articles or comments.
API Response Parsing
Pull specific values from API responses, JSON strings or XML output without writing a full parser.
Understanding Capture Groups in Extraction
Capture groups โ parentheses in your regex pattern โ let you extract sub-parts of each match simultaneously. When you run the pattern (\\d{ 4})-(\\d{ 2})-(\\d{ 2}) against a string containing dates, each match gives you the full date and the year, month and day separately as $1, $2 and $3.
Named capture groups go further โ using (?<year>\\d{4}) creates a group named year that you can reference by name rather than position. This tool shows both numbered and named groups for every match, making it easy to understand exactly what your pattern is capturing.
Extraction vs Find and Replace
These are two complementary operations. Extraction (this tool) reads the string and collects matching values โ the input is unchanged and you get the matches out. Find and Replace (our Regex Find and Replace tool) transforms the string by substituting matches with replacement text.
A typical workflow uses both: first extract to identify and verify your pattern is matching the right things, then switch to Find and Replace to transform or remove those matches in the actual content.
Tips for Writing Extraction Patterns
๐ก Always test with the g flag
Without the global flag, only the first match is returned. This tool adds g automatically, but in your own code remember to include it.
๐ก Use non-greedy quantifiers for bounded matches
Use .*? instead of .* to match the shortest possible string. This prevents one match from consuming text that should be separate matches.
๐ก Anchor appropriately
Use \b for word boundaries to avoid matching partial words. Use ^ and $ with the m flag to match at line boundaries rather than only the start and end of the whole string.
๐ก Test edge cases
Type edge cases directly into the sample text โ empty strings, unicode characters, very long values โ to make sure your pattern handles them correctly before using it in production.
๐ง How It Works
Extract every regex match from any string in seconds
Enter Your Regex Pattern
Type any regular expression pattern, choose flags, or load one of 14 common presets โ emails, URLs, dates, IPs, phone numbers and more.
Paste Your Input String
Paste any text โ API responses, log files, HTML, plain text โ into the input field. Any size string is supported.
Extract All Matches
Click Extract and see every match highlighted, with index positions, capture groups, and export options in multiple formats.
Frequently Asked Questions
Everything about regex match extraction
Do I need to sign up or log in to use this tool?
No. All QuickTextTools are completely free to use online with no login, signup, or account required.
What does this tool do that a regular regex tester doesn't?
This tool is optimised specifically for extraction โ it focuses on getting the matched values out of a string in a usable form. You can export every match as a numbered list, one per line, comma separated, CSV with index positions, or full JSON with groups and metadata. A regular regex tester shows you if something matches. This tool gives you the matched data ready to use.
What regex flags are supported?
The tool supports all JavaScript regex flags: g (global โ extracts all matches), i (case insensitive), m (multiline โ ^ and $ match line boundaries), s (dotAll โ dot matches newline), and u (Unicode mode). The g flag is added automatically when extracting since without it only the first match would be returned.
What are capture groups and how do they work here?
Capture groups are parentheses in your regex pattern that capture a sub-part of the match. For example, (\d{4})-(\d{2})-(\d{2}) captures the year, month and day separately within a date match. This tool shows every capture group for every match โ labelled $1, $2 โ so you can see exactly what was captured.
What is the difference between all matches and unique matches?
All Matches shows every occurrence of the pattern in the input, including duplicates. For example if the word 'the' appears 5 times, all 5 are shown. Unique Matches deduplicates the results and shows each distinct matched string only once. Toggle between them using the Unique Only button above the match list.
What output formats are available?
The tool exports matches in 5 formats: Match List (numbered with full details), One Per Line (each match on its own line, ready to paste), Comma Separated (all matches joined, useful for spreadsheets), CSV (with match number, start index, end index, length and capture groups), and JSON (full structured output with all metadata).
How many matches can the tool extract?
The tool is capped at 5,000 matches per extraction to maintain browser performance. For most practical use cases this limit is never reached. For very large inputs or patterns that produce thousands of matches, consider splitting the input into smaller sections.
What is the difference between this tool and Regex Find and Replace?
This tool is for extraction โ getting the matched values out of text. Regex Find and Replace is for transformation โ replacing matched patterns with something else. If you want to collect all email addresses from a document, use this tool. If you want to remove or change all email addresses in a document, use Regex Find and Replace.
Related Tools
More regex, text and developer tools
Regex Find and Replace
Developer ToolsFind and replace text using regex patterns
Regex Tester
Developer ToolsTest and debug regular expressions live
JSON Formatter
Developer ToolsFormat and beautify JSON data
JWT Decoder
Developer ToolsDecode and inspect JWT tokens
Binary Text Converter
Encode ToolsConvert text to binary, hex and more
Word Counter
Text AnalysisCount words and characters in text