Organízate con las colecciones
Guarda y clasifica el contenido según tus preferencias.
arrays.index_to_int
arrays.index_to_int(array_of_inputs, index)
Descripción
Devuelve el valor de un índice determinado de una matriz como un número entero.
El índice es un valor entero que representa la posición de un elemento en la matriz.
De forma predeterminada, el primer elemento de una matriz tiene el índice 0 y el último elemento tiene el índice n-1, donde n es el tamaño de la matriz.
La indexación negativa permite acceder a los elementos de una matriz en relación con el final de la matriz. Por ejemplo, el índice -1 hace referencia al último elemento de la matriz y el índice -2 hace referencia al penúltimo elemento de la matriz.
Tipos de datos de parámetros
ARRAY_STRINGS|ARRAY_INTS|ARRAY_FLOATS
, INT
Tipo de devolución
INT
Códigos de ejemplo
Ejemplo 1
Esta llamada de función devuelve 0 cuando el valor del índice es una cadena no numérica.
arrays.index_to_int(["str0", "str1", "str2"], 1) = 0
Ejemplo 2
Esta función devuelve el elemento del índice -1.
arrays.index_to_int(["44", "11", "22", "33"], 0-1) = 33
Ejemplo 3
Devuelve 0 para el elemento fuera de los límites.
arrays.index_to_int(["44", "11", "22", "33"], 5) = 0
Ejemplo 4
Esta función obtiene el elemento de la matriz de números de coma flotante en el índice 1.
arrays.index_to_int([1.100000, 1.200000, 1.300000], 1) = 1
Ejemplo 5
Esta función obtiene el elemento de la matriz int en el índice 0.
arrays.index_to_int([1, 2, 3], 0) = 1
A menos que se indique lo contrario, el contenido de esta página está sujeto a la licencia Reconocimiento 4.0 de Creative Commons y las muestras de código están sujetas a la licencia Apache 2.0. Para obtener más información, consulta las políticas del sitio web de Google Developers. Java es una marca registrada de Oracle o sus afiliados.
Última actualización: 2025-08-20 (UTC).
[[["Es fácil de entender","easyToUnderstand","thumb-up"],["Me ofreció una solución al problema","solvedMyProblem","thumb-up"],["Otro","otherUp","thumb-up"]],[["Es difícil de entender","hardToUnderstand","thumb-down"],["La información o el código de muestra no son correctos","incorrectInformationOrSampleCode","thumb-down"],["Me faltan las muestras o la información que necesito","missingTheInformationSamplesINeed","thumb-down"],["Problema de traducción","translationIssue","thumb-down"],["Otro","otherDown","thumb-down"]],["Última actualización: 2025-08-20 (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"]]