Click or drag to resize

Occurs Function

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

Namespace:  XSharp.Core
Assembly:  XSharp.Core (in XSharp.Core.dll) Version: 2.21
Syntax
 FUNCTION Occurs(
	cSearch AS STRING,
	cTarget AS STRING
) AS DWORD
Request Example 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: DWord
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