Note: This release is in preview. Features described here don’t become generally available until the latest general availability date that Salesforce announces for this release. Before then, and where features are noted as beta, pilot, or developer preview, we can’t guarantee general availability within any particular time frame or at all. Make your purchase decisions only on the basis of generally available products and features.
index_of()
Syntax
index_of(string, searchStr [,position [, occurence]])
Usage
The default value of position is 1, which means that the function begins searching at the first character of string. An error results if position is negative or zero.
occurrence is an optional integer, with a default value of 1 . You can use this parameter to specify which occurrence of searchStr to search for. For example, if there is more than one occurrence of searchStr, and occurence is 2, the index of the second occurrence is returned.
Constant values are supported for position and occurrence, not arbitrary expressions.
If searchStr is an empty string, then the function returns null.Example
1q = load "Opportunity Details";
2q = group q by all;
3-- return the first occurrence of "a", starting at the beginning.
4-- The result is 2.
5q = foreach q generate index_of("Hawaii", "a") as 'Index';
6
7-- return the second occurrence of "a", starting at the beginning
8-- the result is 4
9q = foreach q generate index_of("Hawaii", "a",1, 2) as 'Index';
10
11
12-- return the first occurrence of "a", starting at the third position
13-- the result is 4
14q = foreach q generate index_of("Hawaii", "a",3) as 'Index';