npm.io
2.0.1 • Published 1 year ago

string-matches

Licence
MIT
Version
2.0.1
Deps
0
Size
3 kB
Vulns
0
Weekly
0
Stars
1

stringMatches

Retrieves all the matches of a regex in a string.

Install

npm install string-matches

Usage

import stringMatches from 'string-matches';

// Let's get all the matches of a regex in a string

const str = 'A tidy tiger tied a tighter tie to tidy her tiny tail';
const regex = /tidy/g; // Don't forget the `g` flag, or it won't work

const matches = stringMatches ( str, regex );

console.log ( matches.length ); // => 2

License

MIT Fabio Spampinato

Keywords