https://github.com/gajus/extract-email-address
Extracts email address from an arbitrary text input.
https://github.com/gajus/extract-email-address
email extract regex
Last synced: about 1 year ago
JSON representation
Extracts email address from an arbitrary text input.
- Host: GitHub
- URL: https://github.com/gajus/extract-email-address
- Owner: gajus
- License: other
- Created: 2020-05-07T00:15:00.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2025-01-30T17:28:45.000Z (over 1 year ago)
- Last Synced: 2025-03-28T21:01:35.527Z (over 1 year ago)
- Topics: email, extract, regex
- Language: TypeScript
- Size: 35.2 KB
- Stars: 62
- Watchers: 4
- Forks: 8
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://coveralls.io/github/gajus/extract-email-address)
[](https://www.npmjs.org/package/extract-email-address)
[](https://github.com/gajus/canonical)
[](https://twitter.com/kuizinas)
Extracts email-like entities from an arbitrary text input.
* [extract-email-address 📧](#extract-email-address)
* [API](#extract-email-address-api)
* [Usage](#extract-email-address-usage)
* [Filtering results](#extract-email-address-filtering-results)
* [Related projects](#extract-email-address-related-projects)
```js
import {
extractEmail,
type EmailMatch,
} from 'extract-email-address';
extractEmail(input: string): readonly EmailMatch[];
```
```js
import { extractEmail } from 'extract-email-address';
extractEmail('extracts email from anywhere within the input gajus@gajus.com');
// [{email: 'gajus@gajus.com'}]
extractEmail('extracts multiple emails located anywhere within the input: foo@gajus.com, bar@gajus.com');
// [{email: 'foo@gajus.com'}, {email: 'bar@gajus.com'}]
extractEmail('extracts all sorts of obfuscated emails, e.g. f o o @ b a r . c o m or baz [at] qux [dot] com');
// [{email: 'foo@bar.com'}, {email: 'baz@qux.com'}]
extractEmail('extracts tagged emails, e.g. gajus+foo@gajus.com');
// [{email: 'gajus+foo@gajus.com'}]
extractEmail('extracts emails surrounded by odd unicode characters, e.g. 邮箱:gajus@gajus.com');
// [{email: 'gajus@gajus.com'}]
extractEmail('extracts emails surrounded by emojis, e.g. 📧gajus@gajus.com');
// [{email: 'gajus@gajus.com'}]
extractEmail('excludes invalid emails with invalid TLDs, e.g. gajus@gajus.png');
// []
extractEmail('ignores invalid emails foo@bar');
// []
```
Some matches might be syntactically valid email addresses, but not actual email addresses, e.g. `apple-touch-icon@2.png`.
`extract-email-address` uses a list of valid top-level domains to filter out matches that are definitely not emails (such as `png` example), but you might still need to filter out domain specific false-positives.
* [`extract-date`](https://github.com/gajus/extract-date) – Extracts date from an arbitrary text input.
* [`extract-price`](https://github.com/gajus/extract-price) – Extracts price from an arbitrary text input.
* [`extract-time`](https://github.com/gajus/extract-time) – Extracts time from an arbitrary text input.