# string-occurrence

> Get the number of occurrences of a string in a string

Latest version **1.2.0** (published 2015-12-21) · MIT license · 0 weekly downloads

## Install

```sh
npm install string-occurrence
pnpm add string-occurrence
yarn add string-occurrence
bun add string-occurrence
```

## 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.2.0 |
| Published | 2015-12-21 |
| First published | 2015-12-19 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=0.10.0 |
| Dependencies | 2 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 4 |
| Author | Sam Verschueren |
| Maintainers | samverschueren |
| Keywords | string, occurrence, needle, haystack, search, count |

## Links

- npm: https://www.npmjs.com/package/string-occurrence
- Repository: https://github.com/samverschueren/string-occurrence
- Homepage: https://github.com/samverschueren/string-occurrence#readme
- Issues: https://github.com/samverschueren/string-occurrence/issues
- npm.io page: https://npm.io/package/string-occurrence

## Dependencies (2)

- [regex-occurrence](https://npm.io/package/regex-occurrence.md) ^1.0.0
- [escape-string-regexp](https://npm.io/package/escape-string-regexp.md) ^1.0.4

## Alternatives

- [@mce/gif](https://npm.io/package/@mce/gif.md) — 2.6K weekly downloads
- [cleanse](https://npm.io/package/cleanse.md) — 173 weekly downloads
- [str](https://npm.io/package/str.md) — 127 weekly downloads
- [naming](https://npm.io/package/naming.md) — 95 weekly downloads
- [tap-telco-api](https://npm.io/package/tap-telco-api.md) — 19 weekly downloads

## Recent versions

- 1.2.0 (latest) — 2015-12-21
- 1.1.1 — 2015-12-20
- 1.1.0 — 2015-12-19
- 1.0.0 — 2015-12-19

## README

# string-occurrence [![Build Status](https://travis-ci.org/SamVerschueren/string-occurrence.svg?branch=master)](https://travis-ci.org/SamVerschueren/string-occurrence)

> Get the number of occurrences of a string in a string


## Install

```
$ npm install --save string-occurrence
```


## Usage

```js
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.

#### search

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](http://github.com/SamVerschueren)

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