# match-point

> Find all pattern matches and return the specified submatch for each

Latest version **1.0.0** (published 2017-12-25) · MIT license · 0 weekly downloads

## Install

```sh
npm install match-point
pnpm add match-point
yarn add match-point
bun add match-point
```

## 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 | 1.0.0 |
| Published | 2017-12-25 |
| First published | 2017-12-25 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Jonathan Eiten |
| Maintainers | joneit |

## Links

- npm: https://www.npmjs.com/package/match-point
- Repository: https://github.com/joneit/match-point
- Homepage: https://github.com/joneit/match-point#readme
- Issues: https://github.com/joneit/match-point/issues
- npm.io page: https://npm.io/package/match-point

## Recent versions

- 1.0.0 (latest) — 2017-12-25

## README

Find all pattern matches and return the specified submatch for each

### Synposis

```js
function(string, regex, captureGroup)
```

### Usage

```js
var match = require('match-point');
var string = 'Alice A. Adams, MD, Bob B. Baker, BA, Dr. Charlie C. Chase, PhD';
match(string, / ([A-Z])\. /); // ['A', 'B', 'C']
match(string, / ([A-Z])\. \w+, (MD|MS|PhD)/); // ['MD', 'PhD']
match(string, / ([A-Z])\. \w+, (MD|MS|PhD)/, 1); // ['A', 'C']
```

### Description

Find all pattern matches in `string` matching `regex` and return in an array.

For each element:
* When there are no capture groups in the regex, the entire pattern match is returned.
* When there are capture groups in the regex:
   * When `captureGroup` is undefined, the last submatch is returned.
   * When `captureGroup` is defined, it indicates which submatch to return (`0` being the entire match, _etc._, per [`String.prototype.match`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/match) results).

### Caveats

Don't use global flag in your regex. It's unnecessary and suppresses submatches of capture groups.

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