DotNetWikiBot Framework Documentation
This auxiliary function counts the occurrences of specified string in specified text. This count is often required, but strangely there is no such function in .NET Framework's String class.

Namespace: DotNetWikiBot
Assembly: DotNetWikiBot (in DotNetWikiBot.dll) Version: 0.0.0.0

Syntax

C#
public static int CountMatches(
	string text,
	string str,
	bool ignoreCase
)

Parameters

text
Type: System..::..String
String to look in.
str
Type: System..::..String
String to look for.
ignoreCase
Type: System..::..Boolean
Pass "true" if you require case-insensitive search. Case-sensitive search is faster.

Return Value

Type: Int32
Returns the number of found occurrences.

Examples

 Copy imageCopy
int m = Bot.CountMatches("Bot Bot bot", "Bot", false); // m=2

See Also