Count the number of times substr appears in value
Install
Install all functions of strman
yarn add strman
or just the countSubstr function
yarn add strman.countsubstr
Usage
import { countSubstr } from 'strman'
// OR
import countSubstr from 'strman.countsubstr'
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
value |
String | The input string |
||
substr |
String | The substring to look for |
||
caseSensitive |
Boolean |
<optional> |
true | Use case (in-)sensitive matching |
allowOverlapping |
Boolean |
<optional> |
false | Allow overlapping substrings to be counted |
- Source:
Returns:
The number of matches
- Type
- Number
Example
const title = 'Daniel Leite'
const substr = 'Leite'
countSubstr(title, substr)
// => 1