Click or drag to resize

Occurs Function

Return the number of times a substring occurs in a string.

Namespace:  XSharp.Core
Assembly:  XSharp.Core (in XSharp.Core.dll) Version: 2.4a
Syntax
 FUNCTION Occurs(
	cSearch AS STRING,
	cTarget AS STRING
) AS DWORD
View Source

Parameters

cSearch
Type: String
The substring for which to search.
cTarget
Type: String
The string in which to search.  (To specify an offset, use Occurs3()).

Return Value

Type: UInt32
The number of times that <cSearch> appears in <cTarget>.
Remarks
Occurs() is case-sensitive and nation-dependent.
Examples
This example shows typical use of Occurs():
X#
1LOCAL cSearch AS STRING
2LOCAL cTarget AS STRING
3cSearch := "any"
4cTarget := "Anything goes anyway anytime."
5? Occurs(cSearch, cTarget)        // 2
6? Occurs("any","ANY any")            // 1
See Also