Optional
overlapping?: booleanWhether to count overlapping matches, false by default.
occurrences("aaa", "aa") // overlapping false
// aaa
// __
// ^matches
// ^moves to end of match and finds no further matches
occurrences("aaa", "aa", { overlapping:true })
//aaa
//__
//^matches
// ^moves 1 character forward
// __
// ^matches
// ^moves 1 character forward and finds no further matches
Counts the number of times a substring occurs in the given string.
Does not count overlapping matches by default but can be enabled with the
overlapping
option.