コレクションでコンテンツを整理
必要に応じて、コンテンツの保存と分類を行います。
arrays.index_to_int
arrays.index_to_int(array_of_inputs, index)
説明
配列の指定されたインデックスの値を整数として返します。
インデックスは、配列内の要素の位置を表す整数値です。デフォルトでは、配列の最初の要素のインデックスは 0、最後の要素のインデックスは n-1 です。ここで、n は配列のサイズです。負のインデックスを使用すると、配列の末尾を基準にして配列要素にアクセスできます。たとえば、インデックス -1 は配列の最後の要素を参照し、インデックス -2 は配列の最後から 2 番目の要素を参照します。
パラメータのデータ型
ARRAY_STRINGS|ARRAY_INTS|ARRAY_FLOATS
、INT
戻り値の型
INT
コードサンプル
例 1
この関数呼び出しは、インデックスの値が数値以外の文字列の場合に 0 を返します。
arrays.index_to_int(["str0", "str1", "str2"], 1) = 0
例 2
この関数は、インデックス -1 の要素を返します。
arrays.index_to_int(["44", "11", "22", "33"], 0-1) = 33
例 3
範囲外の要素の場合は 0 を返します。
arrays.index_to_int(["44", "11", "22", "33"], 5) = 0
例 4
この関数は、インデックス 1 の float 配列から要素を取得します。
arrays.index_to_int([1.100000, 1.200000, 1.300000], 1) = 1
例 5
この関数は、インデックス 0 の int 配列から要素を取得します。
arrays.index_to_int([1, 2, 3], 0) = 1
特に記載のない限り、このページのコンテンツはクリエイティブ・コモンズの表示 4.0 ライセンスにより使用許諾されます。コードサンプルは Apache 2.0 ライセンスにより使用許諾されます。詳しくは、Google Developers サイトのポリシーをご覧ください。Java は Oracle および関連会社の登録商標です。
最終更新日 2025-07-29 UTC。
[[["わかりやすい","easyToUnderstand","thumb-up"],["問題の解決に役立った","solvedMyProblem","thumb-up"],["その他","otherUp","thumb-up"]],[["わかりにくい","hardToUnderstand","thumb-down"],["情報またはサンプルコードが不正確","incorrectInformationOrSampleCode","thumb-down"],["必要な情報 / サンプルがない","missingTheInformationSamplesINeed","thumb-down"],["翻訳に関する問題","translationIssue","thumb-down"],["その他","otherDown","thumb-down"]],["最終更新日 2025-07-29 UTC。"],[[["\u003cp\u003e\u003ccode\u003earrays.index_to_int\u003c/code\u003e retrieves an element from an array at a specified index and returns it as an integer.\u003c/p\u003e\n"],["\u003cp\u003eThe function supports positive and negative indexing, with negative indices counting from the end of the array.\u003c/p\u003e\n"],["\u003cp\u003eIf the element at the specified index is a non-numeric string or the index is out of bounds, the function returns 0.\u003c/p\u003e\n"],["\u003cp\u003eThe function takes two parameters, the first being the array (that can consist of string, integers or float values), and the second the index (an integer).\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003earrays.index_to_int\u003c/code\u003e is supported in both Rules and Search.\u003c/p\u003e\n"]]],[],null,["### arrays.index_to_int\n\nSupported in: \n[Rules](/chronicle/docs/detection/default-rules) [Search](/chronicle/docs/investigation/udm-search) \n\n arrays.index_to_int(array_of_inputs, index)\n\n#### Description\n\nReturns the value at a given index in an array as an integer.\n\nThe index is an integer value which represents the position of an element in the array.\nBy default, the first element of an array has an index of 0, and the last element has an index of n-1, where n is the size of the array.\nNegative indexing allows accessing array elements relative to the end of the array. For example, an index of -1 refers to the last element in the array and an index of -2 refers to the second to last element in the array.\n\n#### Param data types\n\n`ARRAY_STRINGS|ARRAY_INTS|ARRAY_FLOATS`, `INT`\n\n#### Return type\n\n`INT`\n\n#### Code samples\n\n##### Example 1\n\nThis function call returns 0 when the value at the index is a non-numeric string. \n\n arrays.index_to_int([\"str0\", \"str1\", \"str2\"], 1) = 0\n\n##### Example 2\n\nThis function returns the element at index -1. \n\n arrays.index_to_int([\"44\", \"11\", \"22\", \"33\"], 0-1) = 33\n\n##### Example 3\n\nReturns 0 for the out-of-bounds element. \n\n arrays.index_to_int([\"44\", \"11\", \"22\", \"33\"], 5) = 0\n\n##### Example 4\n\nThis function fetches the element from the float array at index 1. \n\n arrays.index_to_int([1.100000, 1.200000, 1.300000], 1) = 1\n\n##### Example 5\n\nThis function fetches the element from the int array at index 0. \n\n arrays.index_to_int([1, 2, 3], 0) = 1"]]