URLs and punctuation
| Text | Extracted URL |
|---|---|
| See https://example.com/docs. | https://example.com/docs |
| (more at https://example.com/a?b=1) | https://example.com/a?b=1 |
| https://en.wikipedia.org/wiki/Mercury_(planet), the planet | https://en.wikipedia.org/wiki/Mercury_(planet) |
| Visit www.example.org! | www.example.org |
Extracting emails and URLs in code
# Unique emails from a file
grep -Eoi '[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,}' file.txt | sort -fu
# URLs
grep -Eo 'https?://[^[:space:]"<>]+' access.log | sort -u
# IPv4 addresses, most frequent first
grep -Eo '([0-9]{1,3}\.){3}[0-9]{1,3}' access.log | sort | uniq -c | sort -rn
import re
EMAIL = re.compile(r"[\w.%+-]+@(?:[A-Za-z0-9-]+\.)+[A-Za-z]{2,}")
emails = list(dict.fromkeys(m.lower() for m in EMAIL.findall(text)))
const emails = [...new Set(text.match(/[\w.%+-]+@(?:[a-z0-9-]+\.)+[a-z]{2,}/gi) ?? [])];
Need the list as a quoted SQL IN (…) clause or a JSON array? Paste it into the
comma separated list converter. Writing your own pattern? Test it in the
regex tester.
Frequently asked questions
Which email addresses are found?
Addresses in the form people actually use: letters, digits, dots, hyphens, underscores, % and + in the local part (so jane.doe+news@example.com works), and a domain with at least one dot and a letter-only top-level domain. Exotic forms that the RFC allows, like quoted local parts or IP-address domains, are rare in practice and skipped to avoid false matches.
Are duplicates removed?
Yes, by default. Emails, domains and UUIDs are compared case-insensitively, because Jane@Example.com and jane@example.com reach the same mailbox in practice; the first spelling is kept. Tick “Lowercase” to normalise all of them. URLs are compared exactly, since paths can be case-sensitive.
How are URLs at the end of a sentence handled?
Trailing punctuation like a full stop, comma or closing quote is not part of the URL. A closing parenthesis is kept only if the URL contains a matching opening one, so Wikipedia links like …/Mercury_(planet) stay whole, while a URL written in parentheses loses the closing bracket.
Can I extract emails from HTML or a CSV file?
Yes. Paste the HTML source, a CSV, a log file or an email thread; the extractor ignores the surrounding markup. Use Upload or drop the file on the input box. mailto: links are found too, without the mailto: prefix.
Is the text uploaded?
No. Matching runs in your browser, so you can safely paste customer lists or server logs. Only use extracted addresses in line with privacy law and the consent of the people they belong to; sending unsolicited email to scraped addresses is illegal in many countries.