PATINDEX
Applies to: CELONIS 4.7
Description
PATINDEX
searches for the pattern
-substring and returns its index (starting from 1) within the input if it was found (zero otherwise).
Supported input column types: STRING
Output column type: INT
Syntax
PATINDEX ( table.column, pattern [, occurrence ] )
table.column: The string column on which the
PATINDEX
operator is executed.pattern: The pattern which is searched for in the input string.
occurrence: Number of the occurrence of the pattern, defaults to
1
. Only the index of the n-th occurrence of the pattern is returned, if the n-th occurrence exists, otherwise 0 is returned.
NOTE: In general, this operator conforms to the behaviour of MS SQL Server but the parameter order is changed. For consistency with other operators (such as LIKE), the first parameter of PATINDEX
is the input string and the second parameter is the pattern string.
NULL handling
If any of the inputs (table.column
or pattern
) is NULL, the result will be NULL as well.
Examples
[1] Returns the indices where the pattern |
[2] Having a wildcard in the pattern is also supported. |
[3] Using the |
[4] To use the wildcard symbol as an actual character, the wildcard symbol must be escaped. |
[5] Returns the indices where the pattern |
[6] Returns the indices where the pattern |
[7] Returns 0 if there is no n-th occurrence of the pattern. |