Determines if <String2> is contained within <String1> and returns an Integer value equal to the beginning character position of the first occurrence of <String2> within <String1>. If <String1> does not contain <String2>, then a value of 0 (zero) is returned. This operator is similar to .contains but returns different results. A 0 result from .indexOf is equivalent to a false value returned by the .contains operator.
If <String1> contains more than one occurrence of <String2>, .indexOf returns the first character position of the first occurrence. For example: If <String1> holds the String value ‘Mississippi’ and <String2> holds the String value ‘ss’, then the .indexOf operator returns 3. The second occurrence of ‘ss’ beginning at position 6 is not identified.
The following Rulesheet uses .indexOf to evaluate whether string1 includes the characters silver and assigns a value to integer1 corresponding to the beginning character position of the first occurrence.
SAMPLE RULETEST
A sample Ruletest provides string1 values for three examples. Input and Output panels are shown below. Notice sensitivity to case in example 1.