string-occurrence

Get the number of occurrences of a string in a string

MIT 4 个版本
安装
npm install string-occurrence
yarn add string-occurrence
pnpm add string-occurrence
bun add string-occurrence
README

string-occurrence Build Status

Get the number of occurrences of a string in a string

Install

$ npm install --save string-occurrence

Usage

const stringOccurrence = require('string-occurrence');

stringOccurrence('foo bar', 'foo');
//=> 1

stringOccurrence('foo bar\nfoo baz', 'foo');
//=> 2

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

API

stringOccurrence(input, search, [options])

input

Type: string

The string to search in.

Type: string, string[]

The keyword or keywords to search for.

options

caseInsensitive

Type: boolean
Default: true

Perform a case insensitive match.

License

MIT © Sam Verschueren

版本列表
1.2.0 2015-12-21
1.1.1 2015-12-20
1.1.0 2015-12-19
1.0.0 2015-12-19