Mantieni tutto organizzato con le raccolte
Salva e classifica i contenuti in base alle tue preferenze.
strings.concat
strings.concat(a, b, c, ...)
Descrizione
Restituisce la concatenazione di un numero illimitato di elementi, ognuno dei quali può essere
una stringa, un numero intero o un numero in virgola mobile.
Se alcuni argomenti sono campi evento, gli attributi devono provenire dallo stesso evento.
Tipi di dati dei parametri
STRING
, FLOAT
, INT
Tipo restituito
STRING
Esempi di codice
Esempio 1
L'esempio seguente include una variabile stringa e una variabile intera come
argomenti. Sia principal.hostname
che principal.port
provengono dallo stesso
evento, $e
, e vengono concatenati per restituire una stringa.
"google:80" = strings.concat($e.principal.hostname, ":", $e.principal.port)
Esempio 2
Il seguente esempio include una variabile stringa e un valore letterale stringa come argomenti.
"google-test" = strings.concat($e.principal.hostname, "-test") // Matches the event when $e.principal.hostname = "google"
Esempio 3
Il seguente esempio include una variabile stringa e un valore letterale float come argomenti.
Quando sono rappresentati come stringhe, i numeri in virgola mobile che sono numeri interi vengono formattati senza
la virgola decimale (ad esempio, 1.0 è rappresentato come "1"). Inoltre,
i numeri in virgola mobile che superano le sedici cifre decimali vengono troncati alla sedicesima cifra
decimale.
"google2.5" = strings.concat($e.principal.hostname, 2.5)
Esempio 4
L'esempio seguente include una variabile stringa, un valore letterale stringa,
una variabile intera e un valore letterale float come argomenti. Tutte le variabili provengono dallo stesso evento, $e
, e vengono concatenate con i valori letterali per restituire una stringa.
"google-test802.5" = strings.concat($e.principal.hostname, "-test", $e.principal.port, 2.5)
Esempio 5
L'esempio seguente tenta di concatenare principal.port dall'evento $e1
,
con principal.hostname
dall'evento $e2
. Restituirà un errore del compilatore
perché gli argomenti sono variabili evento diverse.
// Will not compile
"test" = strings.concat($e1.principal.port, $e2.principal.hostname)
Salvo quando diversamente specificato, i contenuti di questa pagina sono concessi in base alla licenza Creative Commons Attribution 4.0, mentre gli esempi di codice sono concessi in base alla licenza Apache 2.0. Per ulteriori dettagli, consulta le norme del sito di Google Developers. Java è un marchio registrato di Oracle e/o delle sue consociate.
Ultimo aggiornamento 2025-07-29 UTC.
[[["Facile da capire","easyToUnderstand","thumb-up"],["Il problema è stato risolto","solvedMyProblem","thumb-up"],["Altra","otherUp","thumb-up"]],[["Difficile da capire","hardToUnderstand","thumb-down"],["Informazioni o codice di esempio errati","incorrectInformationOrSampleCode","thumb-down"],["Mancano le informazioni o gli esempi di cui ho bisogno","missingTheInformationSamplesINeed","thumb-down"],["Problema di traduzione","translationIssue","thumb-down"],["Altra","otherDown","thumb-down"]],["Ultimo aggiornamento 2025-07-29 UTC."],[[["\u003cp\u003e\u003ccode\u003estrings.concat\u003c/code\u003e combines multiple strings, integers, or floats into a single string, supporting an unlimited number of arguments.\u003c/p\u003e\n"],["\u003cp\u003eWhen using event fields as arguments within \u003ccode\u003estrings.concat\u003c/code\u003e, all fields must be attributes originating from the same event.\u003c/p\u003e\n"],["\u003cp\u003eThe function supports various data types, including \u003ccode\u003eSTRING\u003c/code\u003e, \u003ccode\u003eFLOAT\u003c/code\u003e, and \u003ccode\u003eINT\u003c/code\u003e, and returns a \u003ccode\u003eSTRING\u003c/code\u003e value after concatenation.\u003c/p\u003e\n"],["\u003cp\u003eFloat numbers in \u003ccode\u003estrings.concat\u003c/code\u003e are formatted as whole numbers without a decimal point when they are whole numbers, and they are truncated to the sixteenth decimal place if exceeding that value.\u003c/p\u003e\n"],["\u003cp\u003eAttempting to concatenate event fields that belong to different events will result in a compiler error.\u003c/p\u003e\n"]]],[],null,["### strings.concat\n\nSupported in: \n[Rules](/chronicle/docs/detection/default-rules) [Search](/chronicle/docs/investigation/udm-search) \n\n strings.concat(a, b, c, ...)\n\n#### Description\n\nReturns the concatenation of an unlimited number of items, each of which can be\na string, integer, or float.\n\nIf any arguments are event fields, the attributes must be from the same event.\n\n#### Param data types\n\n`STRING`, `FLOAT`, `INT`\n\n#### Return type\n\n`STRING`\n\n#### Code samples\n\n##### Example 1\n\nThe following example includes a string variable and integer variable as\narguments. Both `principal.hostname` and `principal.port` are from the same\nevent, `$e`, and are concatenated to return a string. \n\n \"google:80\" = strings.concat($e.principal.hostname, \":\", $e.principal.port)\n\n##### Example 2\n\nThe following example includes a string variable and string literal as arguments. \n\n \"google-test\" = strings.concat($e.principal.hostname, \"-test\") // Matches the event when $e.principal.hostname = \"google\"\n\n##### Example 3\n\nThe following example includes a string variable and float literal as arguments.\nWhen represented as strings, floats that are whole numbers are formatted without\nthe decimal point (for example, 1.0 is represented as \"1\"). Additionally,\nfloats that exceed sixteen decimal digits are truncated to the sixteenth decimal\nplace. \n\n \"google2.5\" = strings.concat($e.principal.hostname, 2.5)\n\n##### Example 4\n\nThe following example includes a string variable, string literal,\ninteger variable, and float literal as arguments. All variables are from the\nsame event, `$e`, and are concatenated with the literals to return a string. \n\n \"google-test802.5\" = strings.concat($e.principal.hostname, \"-test\", $e.principal.port, 2.5)\n\n##### Example 5\n\nThe following example attempts to concatenate principal.port from event `$e1`,\nwith `principal.hostname` from event `$e2`. It will return a compiler error\nbecause the arguments are different event variables. \n\n // Will not compile\n \"test\" = strings.concat($e1.principal.port, $e2.principal.hostname)"]]