Skip to content

Function: count()

ts
function count(text, substring): number;

Counts how many times substring appears in text. 统计子串在文本中出现的次数。

Parameters

ParameterTypeDescription
textstringSource text / 源文本
substringstringSubstring to count / 子串

Returns

number

Occurrence count / 出现次数

Example

ts
count('abcabc', 'a')
// => 2

Since

1.2.0

Released under the MIT License.