Description

Case-insensitive version of the Index() function. Examines a string for the occurrence of a specified substring. Returns the starting position of the designated substring in the string. Index() is case sensitive, meaning that the match must be exact. Use index() for a case-sensitive match ("Abc" does not match "ABC").

Syntax

position = Indexc (string, substring, occurrence)

Parameters

The Indexc function has the following parameters.

ParameterDescription
StringAny legal data, including a null.
SubstringThe substring for which to search in string.
OccurrenceDefines which occurrence of substring to locate (presuming the possible existence of more than one).

The Indexc function returns a numeric value that is the starting character position of substring within the string expression. In the following example:

FIRST = Indexc("ABracAdabrA", "caD", 1)

the variable identifier FIRST is assigned the value of 5 because the first occurrence of the substring "caD" begins in character position 5 in the string "ABracAbrA." In this example:

T = Indexc("XXA1YYa1ZZA1," "A1," 3) T would be assigned the numeric value of 11 because the third occurrence of "A1" (regardless of case) begins in character position 11.

If the specified occurrence does not exist, or if the substring is not found, a value of zero is returned.

In the above example, if the last expression had been 4, a 0 (zero) would have resulted because the string A1 does not occur four times. A value of 0 (zero) would have resulted also if the substring "2" had been used because the substring does not exist in the string

See also

index()

Example

This statement checks if a variable contains more than one field.

if Indexc (var, @FM, 1) then
  * there are multiple fields
end

This statement removes the second occurrence of "the" (regardless of case) from a string.

POS = Indexc(VAR, "thE",2)
If POS Then VAR [POS, Len("the")] = ""
  • No labels