Mit Sammlungen den Überblick behalten
Sie können Inhalte basierend auf Ihren Einstellungen speichern und kategorisieren.
arrays.index_to_int
arrays.index_to_int(array_of_inputs, index)
Beschreibung
Gibt den Wert an einem bestimmten Index in einem Array als Ganzzahl zurück.
Der Index ist ein ganzzahliger Wert, der die Position eines Elements im Array darstellt.
Standardmäßig hat das erste Element eines Arrays den Index 0 und das letzte Element den Index n–1, wobei n die Größe des Arrays ist.
Mit der negativen Indexierung kann auf Arrayelemente relativ zum Ende des Arrays zugegriffen werden. Ein Index von -1 verweist beispielsweise auf das letzte Element im Array und ein Index von -2 auf das vorletzte Element im Array.
Parameterdatentypen
ARRAY_STRINGS|ARRAY_INTS|ARRAY_FLOATS
, INT
Rückgabetyp
INT
Codebeispiele
Beispiel 1
Dieser Funktionsaufruf gibt 0 zurück, wenn der Wert am Index ein nicht numerischer String ist.
arrays.index_to_int(["str0", "str1", "str2"], 1) = 0
Beispiel 2
Diese Funktion gibt das Element am Index -1 zurück.
arrays.index_to_int(["44", "11", "22", "33"], 0-1) = 33
Beispiel 3
Gibt 0 für das Element außerhalb des gültigen Bereichs zurück.
arrays.index_to_int(["44", "11", "22", "33"], 5) = 0
Beispiel 4
Diese Funktion ruft das Element aus dem Gleitkomma-Array am Index 1 ab.
arrays.index_to_int([1.100000, 1.200000, 1.300000], 1) = 1
Beispiel 5
Diese Funktion ruft das Element aus dem int-Array am Index 0 ab.
arrays.index_to_int([1, 2, 3], 0) = 1
Sofern nicht anders angegeben, sind die Inhalte dieser Seite unter der Creative Commons Attribution 4.0 License und Codebeispiele unter der Apache 2.0 License lizenziert. Weitere Informationen finden Sie in den Websiterichtlinien von Google Developers. Java ist eine eingetragene Marke von Oracle und/oder seinen Partnern.
Zuletzt aktualisiert: 2025-07-29 (UTC).
[[["Leicht verständlich","easyToUnderstand","thumb-up"],["Mein Problem wurde gelöst","solvedMyProblem","thumb-up"],["Sonstiges","otherUp","thumb-up"]],[["Schwer verständlich","hardToUnderstand","thumb-down"],["Informationen oder Beispielcode falsch","incorrectInformationOrSampleCode","thumb-down"],["Benötigte Informationen/Beispiele nicht gefunden","missingTheInformationSamplesINeed","thumb-down"],["Problem mit der Übersetzung","translationIssue","thumb-down"],["Sonstiges","otherDown","thumb-down"]],["Zuletzt aktualisiert: 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"]]