Bewerken

Delen via


has_any_index()

Applies to: ✅ Microsoft FabricAzure Data ExplorerAzure MonitorMicrosoft Sentinel

Searches the string for items specified in the array and returns the position in the array of the first item found in the string.

Syntax

has_any_index (source, values)

Learn more about syntax conventions.

Parameters

Name Type Required Description
source string ✔️ The value to search.
values dynamic ✔️ An array of scalar or literal expressions to look up.

Returns

Zero-based index position of the first item in values that is found in source. Returns -1 if none of the array items were found in the string or if values is empty.

Example

print
 idx1 = has_any_index("this is an example", dynamic(['this', 'example']))  // first lookup found in input string
 , idx2 = has_any_index("this is an example", dynamic(['not', 'example'])) // last lookup found in input string
 , idx3 = has_any_index("this is an example", dynamic(['not', 'found'])) // no lookup found in input string
 , idx4 = has_any_index("Example number 2", range(1, 3, 1)) // Lookup array of integers
 , idx5 = has_any_index("this is an example", dynamic([]))  // Empty lookup array

Output

idx1 idx2 idx3 idx4 idx5
0 1 -1 1 -1