Restez organisé à l'aide des collections
Enregistrez et classez les contenus selon vos préférences.
strings.concat
strings.concat(a, b, c, ...)
Description
Renvoie la concaténation d'un nombre illimité d'éléments, chacun pouvant être une chaîne, un entier ou un float.
Si des arguments sont des champs d'événement, les attributs doivent provenir du même événement.
Types de données des paramètres
STRING
, FLOAT
, INT
Type renvoyé
STRING
Exemples de code
Exemple 1
L'exemple suivant inclut une variable de chaîne et une variable entière en tant qu'arguments. principal.hostname
et principal.port
proviennent du même événement, $e
, et sont concaténés pour renvoyer une chaîne.
"google:80" = strings.concat($e.principal.hostname, ":", $e.principal.port)
Exemple 2
L'exemple suivant inclut une variable de chaîne et un littéral de chaîne en tant qu'arguments.
"google-test" = strings.concat($e.principal.hostname, "-test") // Matches the event when $e.principal.hostname = "google"
Exemple 3
L'exemple suivant inclut une variable de chaîne et un littéral float comme arguments.
Lorsqu'ils sont représentés sous forme de chaînes, les nombres à virgule flottante entiers sont mis en forme sans point décimal (par exemple, 1.0 est représenté par "1"). De plus, les nombres à virgule flottante qui dépassent seize chiffres après la virgule sont tronqués au seizième chiffre après la virgule.
"google2.5" = strings.concat($e.principal.hostname, 2.5)
Exemple 4
L'exemple suivant inclut une variable de chaîne, un littéral de chaîne, une variable entière et un littéral flottant en tant qu'arguments. Toutes les variables proviennent du même événement, $e
, et sont concaténées avec les littéraux pour renvoyer une chaîne.
"google-test802.5" = strings.concat($e.principal.hostname, "-test", $e.principal.port, 2.5)
Exemple 5
L'exemple suivant tente de concaténer principal.port de l'événement $e1
avec principal.hostname
de l'événement $e2
. Une erreur de compilation sera renvoyée, car les arguments sont des variables d'événement différentes.
// Will not compile
"test" = strings.concat($e1.principal.port, $e2.principal.hostname)
Sauf indication contraire, le contenu de cette page est régi par une licence Creative Commons Attribution 4.0, et les échantillons de code sont régis par une licence Apache 2.0. Pour en savoir plus, consultez les Règles du site Google Developers. Java est une marque déposée d'Oracle et/ou de ses sociétés affiliées.
Dernière mise à jour le 2025/07/29 (UTC).
[[["Facile à comprendre","easyToUnderstand","thumb-up"],["J'ai pu résoudre mon problème","solvedMyProblem","thumb-up"],["Autre","otherUp","thumb-up"]],[["Difficile à comprendre","hardToUnderstand","thumb-down"],["Informations ou exemple de code incorrects","incorrectInformationOrSampleCode","thumb-down"],["Il n'y a pas l'information/les exemples dont j'ai besoin","missingTheInformationSamplesINeed","thumb-down"],["Problème de traduction","translationIssue","thumb-down"],["Autre","otherDown","thumb-down"]],["Dernière mise à jour le 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)"]]