適用対象: ✅Microsoft Fabric✅Azure データ エクスプローラー✅Azure Monitor✅Microsoft Sentinel
指定した項目の配列を検索し、その位置を返します。
構文
array_index_of(
array,
value [,
start [,
length [,
occurrence ]])
構文規則について詳しく知る。
パラメーター
件名 | タイプ | 必須 | 説明 |
---|---|---|---|
配列 | dynamic |
✔️ | 検索する配列。 |
価値 | long、int、datetime、timespan、string、guid、または bool | ✔️ | 参照する値。 |
を開始 | int |
検索の開始位置。 負の値を指定すると、開始abs( オフセットされます。 |
|
長さ | int |
調べる値の数。 値 -1 は、無制限を意味します。 | |
事象 | int |
出現回数。 既定値は 1 です。 |
返品
検索の 0 から始まるインデックス位置を返します。 値が配列に見つからない場合は -1 を返します。 無関係な入力 (nullを返します。
例示
次の例は、配列内の特定の単語の位置番号を示しています。
let arr=dynamic(["this", "is", "an", "example", "an", "example"]);
print
idx1 = array_index_of(arr,"an") // lookup found in input string
, idx2 = array_index_of(arr,"example",1,3) // lookup found in researched range
, idx3 = array_index_of(arr,"example",1,2) // search starts from index 1, but stops after 2 values, so lookup can't be found
, idx4 = array_index_of(arr,"is",2,4) // search starts after occurrence of lookup
, idx5 = array_index_of(arr,"example",2,-1) // lookup found
, idx6 = array_index_of(arr, "an", 1, -1, 2) // second occurrence found in input range
, idx7 = array_index_of(arr, "an", 1, -1, 3) // no third occurrence in input array
, idx8 = array_index_of(arr, "an", -3) // negative start index will look at last 3 elements
, idx9 = array_index_of(arr, "is", -4) // negative start index will look at last 3 elements
出力
イド×1 | IDX2 | IDX3 | IDX4 | イドクス5 | IDX6 | イドクス7 | IDX8 | IDX9 |
---|---|---|---|---|---|---|---|---|
2 | 3 | -1 | -1 | 3 | 4 | -1 | 4 | -1 |
関連するコンテンツ
set_has_element(arr
,value
)を使用して、配列に値が存在するかどうかを確認します。 この関数により、クエリの読みやすさが向上します。 どちらの関数もパフォーマンスは同じです。