# credit-card-regex

> Regular expression for matching credit card numbers

Latest version **3.0.0** (published 2019-01-21) · MIT license · 0 weekly downloads

## Install

```sh
npm install credit-card-regex
pnpm add credit-card-regex
yarn add credit-card-regex
bun add credit-card-regex
```

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 3.0.0 |
| Published | 2019-01-21 |
| First published | 2014-11-22 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=8 |
| Dependencies | 0 |
| Unpacked size | 3.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 79 |
| Author | Kevin Mårtensson |
| Maintainers | kevva |
| Keywords | americanexpress, creditcard, dinersclub, discover, jcb, maestro, mastercard, number, regex, string, visa |

## Links

- npm: https://www.npmjs.com/package/credit-card-regex
- Repository: https://github.com/kevva/credit-card-regex
- Homepage: https://github.com/kevva/credit-card-regex#readme
- Issues: https://github.com/kevva/credit-card-regex/issues
- npm.io page: https://npm.io/package/credit-card-regex

## Alternatives

- [random-seedable](https://npm.io/package/random-seedable.md) — 27.9K weekly downloads
- [n2words](https://npm.io/package/n2words.md) — 22.2K weekly downloads
- [@stdlib/math-base-special-factorialln](https://npm.io/package/@stdlib/math-base-special-factorialln.md) — 5.7K weekly downloads
- [@stdlib/math-base-special-abs2](https://npm.io/package/@stdlib/math-base-special-abs2.md) — 1.7K weekly downloads
- [commons-math-interpolation](https://npm.io/package/commons-math-interpolation.md) — 1.4K weekly downloads

## Recent versions

- 3.0.0 (latest) — 2019-01-21
- 2.0.0 — 2017-05-22
- 1.3.1 — 2017-05-22
- 1.3.0 — 2017-05-21
- 1.2.3 — 2015-06-18
- 1.2.2 — 2015-04-28
- 1.2.1 — 2015-04-28
- 1.2.0 — 2014-11-23
- 1.1.0 — 2014-11-22
- 1.0.1 — 2014-11-22

## README

# credit-card-regex [![Build Status](https://travis-ci.org/kevva/credit-card-regex.svg?branch=master)](https://travis-ci.org/kevva/credit-card-regex)

> Regular expression for matching credit card numbers


## Install

```
$ npm install credit-card-regex
```


## Usage

```js
const creditCardRegex = require('credit-card-regex');

creditCardRegex().test('6011881485017922 foo bar');
//=> true

creditCardRegex({exact: true}).test('6011881485017922 foo bar');
//=> false

creditCardRegex({exact: true}).test('6011881485017922');
//=> true

'foo 6011881485017922 bar 5441068611005540'.match(creditCardRegex());
//=> ['6011881485017922', '5441068611005540']
```


## API

### creditCardRegex(options)

Returns a regex for matching credit card numbers. It supports credit card numbers from the following vendors:

* American Express
* Diners Club
* Discover
* JCB
* Maestro
* MasterCard
* VISA

#### options

##### exact

Type: `Boolean`<br>
Default: `false` *(Matches any credit card number in a string)*

Only match an exact string. Useful with `RegExp#test` to check if a string is a credit card number.


## License

MIT © [Kevin Mårtensson](https://github.com/kevva)

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