From 964cf565c90298cf289dae95bc5f38725e497a19 Mon Sep 17 00:00:00 2001 From: James Rodewig Date: Wed, 8 Apr 2020 13:49:15 -0400 Subject: [PATCH] [DOCS] EQL: Document `between` function (#54950) --- docs/reference/eql/functions.asciidoc | 113 ++++++++++++++++++++++++++ 1 file changed, 113 insertions(+) diff --git a/docs/reference/eql/functions.asciidoc b/docs/reference/eql/functions.asciidoc index 33f9d2cab35..23b1c9157d6 100644 --- a/docs/reference/eql/functions.asciidoc +++ b/docs/reference/eql/functions.asciidoc @@ -8,11 +8,124 @@ experimental::[] {es} supports the following EQL functions: +* <> * <> * <> * <> * <> +[discrete] +[[eql-fn-between]] +=== `between` + +Extracts a substring that's between a provided `left` and `right` text in a +source string. + +[%collapsible] +==== +*Example* +[source,eql] +---- +// file.path = "C:\\Windows\\System32\\cmd.exe" +between(file.path, "system32\\\\", ".exe") // returns "cmd" +between(file.path, "workspace\\\\", ".exe") // returns "" + + +// Greedy matching defaults to false. +between(file.path, "\\\\", "\\\\", false) // returns "Windows" +// Sets greedy matching to true +between(file.path, "\\\\", "\\\\", true) // returns "Windows\\System32" + +// Case sensitivity defaults to false. +between(file.path, "system32\\\\", ".exe", false, false) // returns "cmd" +// Sets case sensitivity to true +between(file.path, "system32\\\\", ".exe", false, true) // returns "" +between(file.path, "System32\\\\", ".exe", false, true) // returns "cmd" + +// empty source string +between("", "system32\\\\", ".exe") // returns "" +between("", "", "") // returns "" + +// null handling +between(null, "system32\\\\", ".exe") // returns null +---- + +*Syntax* + +[source,txt] +---- +between(, , [, , ]) +---- + +*Parameters* + +``:: ++ +-- +(Required, string or `null`) +Source string. Empty strings return an empty string (`""`), regardless of the +`` or `` parameters. If `null`, the function returns `null`. + +If using a field as the argument, this parameter only supports the following +field datatypes: + +* <> +* <> +* <> field with a <> or + <> sub-field + +Fields containing <> use the first array item only. +-- + +``:: ++ +-- +(Required, string) +Text to the left of the substring to extract. This text should include +whitespace. + +If using a field as the argument, this parameter only supports the following +field datatypes: + +* <> +* <> +* <> field with a <> or + <> sub-field + +<> are not supported. +-- + +``:: ++ +-- +(Required, string) +Text to the right of the substring to extract. This text should include +whitespace. + +If using a field as the argument, this parameter only supports the following +field datatypes: + +* <> +* <> +* <> field with a <> or + <> sub-field + +<> are not supported. +-- + +``:: +(Optional, boolean) +If `true`, match the longest possible substring, similar to `.*` in regular +expressions. If `false`, match the shortest possible substring, similar to `.*?` +in regular expressions. Defaults to `false`. + +``:: +(Optional, boolean) +If `true`, matching is case-sensitive. Defaults to `false`. + +*Returns:* string or `null` +==== + [discrete] [[eql-fn-endswith]] === `endsWith`