Count the occurrences of a substring.
Numeric.string.count(text, needle)Counts non-overlapping matches inside each string.
- Parameters:
text: String or array of strings to searchneedle: Substring whose occurrences are counted
- Returns: Match counts matching the input shape
- NumPy: Covers
np.strings.count,np.char.countthrough a single Numerix method.
import Numeric from '@neabyte/numerix'
const count = Numeric.string.count('hello', 'l')
console.log(count)
// 2import Numeric from '@neabyte/numerix'
const count = Numeric.string.count('hello', 'z')
console.log(count)
// 0import Numeric from '@neabyte/numerix'
const counts = Numeric.string.count(['hello', 'lll'], 'l')
console.log(counts)
// [2,3]import Numeric from '@neabyte/numerix'
const count = Numeric.string.count('aaaa', 'aa')
console.log(count)
// 2