New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

regex-occurrence

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

regex-occurrence

Get the number of occurrences of a RegExp in a string

1.0.0
latest
Source
npm
Version published
Maintainers
1
Created
Source

regex-occurrence Build Status

Get the number of occurrences of a RegExp in a string

Install

$ npm install --save regex-occurrence

Usage

const regexOccurrence = require('regex-occurrence');

regexOccurrence('foo bar', /F/);
//=> 0

regexOccurrence('foo bar', /Foo/i);
//=> 1

regexOccurrence('foo bar\nfoo baz', [/foo/, /baz/]);
//=> 2

regexOccurrence('foo bar\nfoo baz', [/foo/g, /baz/]);
//=> 3

API

input

Type: string

The string to search in.

Type: RegExp, RegExp[]

The regular expressions to search for.

License

MIT © Sam Verschueren

Keywords

regex

FAQs

Package last updated on 21 Dec 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts