Skip to content

Commit 59435c3

Browse files
committed
[DOCS] EQL: Document between function
1 parent cf9603c commit 59435c3

File tree

1 file changed

+118
-0
lines changed

1 file changed

+118
-0
lines changed

docs/reference/eql/functions.asciidoc

Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,129 @@ experimental::[]
88

99
{es} supports the following EQL functions:
1010

11+
* <<eql-fn-between>>
1112
* <<eql-fn-endswith>>
1213
* <<eql-fn-length>>
1314
* <<eql-fn-startswith>>
1415
* <<eql-fn-substring>>
1516

17+
[discrete]
18+
[[eql-fn-between]]
19+
=== `between`
20+
21+
Extracts a substring that's between a provided `left` and `right` text in a
22+
source string.
23+
24+
[%collapsible]
25+
====
26+
*Example*
27+
[source,eql]
28+
----
29+
// file.path = "C:\\Windows\\System32\\cmd.exe"
30+
between(file.path, "system32\\\\", ".exe") // returns "cmd"
31+
between(file.path, "workspace\\\\", ".exe") // returns ""
32+
33+
34+
// Greedy matching defaults to false.
35+
between(file.path, "\\\\", "\\\\", false) // returns "Windows"
36+
// Sets greedy matching to true
37+
between(file.path, "\\\\", "\\\\", true) // returns "Windows\\System32"
38+
39+
// Case sensitivity defaults to false.
40+
between(file.path, "system32\\\\", ".exe", false, false) // returns "cmd"
41+
// Sets case sensitivity to true
42+
between(file.path, "system32\\\\", ".exe", false, true) // returns ""
43+
between(file.path, "System32\\\\", ".exe", false, true) // returns "cmd"
44+
45+
// empty source string
46+
between("", "system32\\\\", ".exe") // returns ""
47+
between("", "", "") // returns ""
48+
49+
// null handling
50+
between(null, "system32\\\\", ".exe") // returns null
51+
between(null, null, null) // returns null
52+
between(file.path, null, ".exe") // returns 400 error
53+
between(file.path, "system32\\\\", null) // returns 400 error
54+
between(file.path, "system32\\\\", ".exe", null) // returns 400 error
55+
between(file.path, "system32\\\\", ".exe", false, null) // returns 400 error
56+
----
57+
58+
*Syntax*
59+
60+
[source,txt]
61+
----
62+
between(<source>, <left>, <right>[, <greedy_matching>, <case_sensitive>])
63+
----
64+
65+
*Parameters*
66+
67+
`<source>`::
68+
+
69+
--
70+
(Required, string or `null`)
71+
Source string. Empty strings return an empty string (`""`), regardless of the
72+
`<left>` or `<right>` parameters. If `null`, the function returns `null`.
73+
74+
If using a field as the argument, this parameter only supports the following
75+
field datatypes:
76+
77+
* <<keyword,`keyword`>>
78+
* <<constant-keyword,`constant_keyword`>>
79+
* <<text,`text`>> field with a <<keyword,`keyword`>> or
80+
<<constant-keyword,`constant_keyword`>> sub-field
81+
82+
Fields containing <<array,array values>> use the first array item only.
83+
--
84+
85+
`<left>`::
86+
+
87+
--
88+
(Required, string)
89+
Text to the left of the substring to extract. This text should include
90+
whitespace.
91+
92+
If using a field as the argument, this parameter only supports the following
93+
field datatypes:
94+
95+
* <<keyword,`keyword`>>
96+
* <<constant-keyword,`constant_keyword`>>
97+
* <<text,`text`>> field with a <<keyword,`keyword`>> or
98+
<<constant-keyword,`constant_keyword`>> sub-field
99+
100+
<<array,Array values>> are not supported.
101+
--
102+
103+
`<right>`::
104+
+
105+
--
106+
(Required, string)
107+
Text to the right of the substring to extract. This text should include
108+
whitespace.
109+
110+
If using a field as the argument, this parameter only supports the following
111+
field datatypes:
112+
113+
* <<keyword,`keyword`>>
114+
* <<constant-keyword,`constant_keyword`>>
115+
* <<text,`text`>> field with a <<keyword,`keyword`>> or
116+
<<constant-keyword,`constant_keyword`>> sub-field
117+
118+
<<array,Array values>> are not supported.
119+
--
120+
121+
`<greedy_matching>`::
122+
(Optional, boolean)
123+
If `true`, match the longest possible substring, similar to `.*` in regular
124+
expressions. If `false`, match the shortest possible substring, similar to `.*?`
125+
in regular expressions. Defaults to `false`.
126+
127+
`<case_sensitive>`::
128+
(Optional, boolean)
129+
If `true`, matching is case-sensitive. Defaults to `false`.
130+
131+
*Returns:* string or `null`
132+
====
133+
16134
[discrete]
17135
[[eql-fn-endswith]]
18136
=== `endsWith`

0 commit comments

Comments
 (0)