count

Summary

Counts the occurrences of the specified substring in the string.

Usage

public unsigned int count(string substr)

Returns

The number of occurrences of the specified substring in the string.

Parameters

substr

The substring to count.

Description

Counts the number of occurrences of the specified substring in the string. The counting operation is case-sensitive.

Examples

Basic Usage
1
2
3
4
5
6
import System;
 
string str = "abc 123 abc 123";
Console.log(str.count("abc")); // 2
Console.log(str.count("123")); // 2
Console.log(str.count("456")); // 0

Share

HTML | BBCode | Direct Link