Click or drag to resize

Occurs2 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.19
Syntax
 FUNCTION Occurs2(
	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
Occurs2() is the same as Occurs().
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? Occurs2(cSearch, cTarget)        // 2
6? Occurs2("any","ANY any")        // 1
See Also