# detect-phonenumber

> Detect phonenumber from string.

Latest version **1.0.5** (published 2022-08-19) · MIT license · 0 weekly downloads

## Install

```sh
npm install detect-phonenumber
pnpm add detect-phonenumber
yarn add detect-phonenumber
bun add detect-phonenumber
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.5 |
| Published | 2022-08-19 |
| First published | 2022-08-06 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 24.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Vladimir Trotsenko |
| Maintainers | keeeparis |
| Keywords | js, phonenumber |

## Links

- npm: https://www.npmjs.com/package/detect-phonenumber
- Repository: https://github.com/keeeparis/detect-phonenumber
- Homepage: https://github.com/keeeparis/detect-phonenumber#readme
- Issues: https://github.com/keeeparis/detect-phonenumber/issues
- npm.io page: https://npm.io/package/detect-phonenumber

## Alternatives

- [@mapbox/jsonlint-lines-primitives](https://npm.io/package/@mapbox/jsonlint-lines-primitives.md) — 5.3M weekly downloads
- [reftools](https://npm.io/package/reftools.md) — 3.5M weekly downloads
- [@hey-api/openapi-ts](https://npm.io/package/@hey-api/openapi-ts.md) — 3.5M weekly downloads
- [@mapbox/geojson-rewind](https://npm.io/package/@mapbox/geojson-rewind.md) — 2.4M weekly downloads
- [turbo-stream](https://npm.io/package/turbo-stream.md) — 1.7M weekly downloads

## Recent versions

- 1.0.5 (latest) — 2022-08-19
- 1.0.4 — 2022-08-06
- 1.0.3 — 2022-08-06
- 1.0.2 — 2022-08-06
- 1.0.1 — 2022-08-06
- 1.0.0 — 2022-08-06

## README

# detect-phonenumber
NPM package to detect phonenumber.

## Installation

```bash
npm install detect-phonenumber
yarn add detect-phonenumber
```

## Usage
You can check whether string contains phonenumber(s).

```js
import detectPhonenumber from 'detect-phonenumber'

detectPhonenumber('8 (800) 555-35-35') // true
detectPhonenumber('8 (800) 555-35-35 another text here +77028012982') // true
detectPhonenumber('some text without number') // false
```

Also, if you pass second argument as `true`, you will get array of objects divided by phonenumber and text. Use case - you want to highlight phonenumber in text.

```js
import detectPhonenumber from 'detect-phonenumber'

detectPhonenumber('8 (800) 555-35-35', true) // [{type: 'number', value: '8 (800) 555-35-35'}]
detectPhonenumber('8 (800) 555-35-35 another text here +77028012982', true) // [{type: 'number', value: '8 (800) 555-35-35'}, {type: 'text', value: ' another text here '}, {type: 'number', value: '+77028012982'}]
detectPhonenumber('some text without number', true) // false
```

## Phonenumber formats to check against
```js
1. +77750002248
2. 87051009263 // starts without +
3. +7 701 772 6172 // with spaces
4. +7 775 065 00 11
5. +7(775)0650011 // with brackets, without spaces
6. +7-775-065-00-11 // separated by dash
7. +7 775.065.00.11 // separeted by dot
```
If you want to add more formats, you can open issue or PR. I will be happy to add them.

## Test:
To run tests, use the following command:
```bash
npm run test
```

## License
MIT

## Author
[Vladimir Trotsenko](https://github.com/keeeparis)

---
_Source: https://npm.io/package/detect-phonenumber · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
