How to Extract IDs, Emails, IPs, and URLs from Text with Regex
Use regex to extract identifiers, email addresses, IP addresses, URLs, UUIDs, order IDs, and request IDs from pasted text, logs, CSV snippets, and support tickets.
Turn messy text into extracted values
Regex extraction is useful when a file, ticket, log, or copied page contains the values you need but not in a clean table. You can match email addresses, IPs, URLs, UUIDs, order IDs, and request IDs, then copy the results into a report or another tool.
When to use this guide
Support tickets
Pull customer IDs, email addresses, order numbers, and URLs from pasted conversations.
Log analysis
Extract request IDs, IP addresses, route paths, and status codes from repeated log lines.
Data migration
Recover useful identifiers from semi-structured text before creating a CSV or JSON file.
Security review
Find URLs, wrapped links, IPs, or tokens inside a copied email or report.
Extraction workflow
Paste the real text
Select examples of the value
Generate and test the pattern
Copy the extracted list
Starter extraction patterns
| Task | Input | Result |
|---|---|---|
ava@example.com | [A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,} | |
| IPv4 | 192.168.1.10 | \b(?:\d{1,3}\.){3}\d{1,3}\b |
| UUID | 550e8400-e29b-41d4-a716-446655440000 | \b[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-5][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}\b |
| URL | https://example.com/path?q=1 | https?:\/\/[^\s"'<>]+ |
Extraction patterns vs validation patterns
Extraction regex and validation regex are different jobs. Extraction should find useful candidates inside messy text. Validation should prove a single value follows a strict format.
Use broad matching for extraction
Use strict matching for forms
Deduplicate after matching
Normalize before sharing
Text extraction checklist
- 1Include at least three examples of the target value and one example that should not match.
- 2Check whether trailing commas, periods, brackets, or quotes are accidentally included.
- 3Prefer custom ID rules when your organization uses prefixes such as
usr_,ord_, orreq_. - 4Remove private or unnecessary values before sharing the extracted list.
Extraction quality checklist
- Use word boundaries around IDs when possible.
- Test with values at the start, middle, and end of a line.
- Check whether punctuation after a value is being captured accidentally.
- Deduplicate extracted values before sharing them.
Privacy note
Related workflow
This guide is designed to pair with the tool linked below. Use the article to understand the workflow, then open the tool with a real sample so you can validate the result instead of copying a generic answer from a search result.
Common mistakes to avoid
- Using an email regex as a validator when you only need extraction.
- Capturing trailing punctuation after URLs copied from prose.
- Assuming every ID format is global. Many teams have custom prefixes and lengths.
- Forgetting case-insensitive matching for hexadecimal IDs.
FAQ
Can regex extract values from CSV?
Is the simple IPv4 regex enough?
How do I extract repeated values only once?
Try it in Regex Generator
Try It Now
Put this guide into practice with our free tools. No sign-up required.
Open Regex Generator