Skip to content

Retrieves all the matches of a regex in a string.

License

Notifications You must be signed in to change notification settings

fabiospampinato/string-matches

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

stringMatches

Retrieves all the matches of a regex in a string.

Install

npm install --save string-matches

Usage

import stringMatches from 'string-matches';

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

stringMatches ( str, regex ).length; // 2

Related

  • string-replace-all - Replaces all the occurrences of a string into a string with another string.

License

MIT © Fabio Spampinato