OpenSearch/docs/reference/eql/functions.asciidoc
James Rodewig 30a32040d3
[DOCS] EQL: Document substring function (#53867)
Adds documentation for the EQL `substring` function.

Supporting changes:

* Creates a new "EQL function reference" page
* Updates the title of the "EQL syntax reference" page for consistency
* Adds a brief "Functions" section to the EQL syntax docs
* Updates EQL limitations docs to state that only array functions are
  unsupported
2020-03-25 12:23:59 -04:00

66 lines
1.4 KiB
Plaintext

[[eql-function-ref]]
== EQL function reference
++++
<titleabbrev>Function reference</titleabbrev>
++++
experimental::[]
{es} supports the following EQL functions:
* <<eql-fn-substring>>
[discrete]
[[eql-fn-substring]]
=== `substring`
Extracts a substring from a source string at provided start and end positions.
If no end position is provided, the function extracts the remaining string.
[%collapsible]
====
*Example*
[source,eql]
----
substring("start regsvr32.exe", 6) // returns "regsvr32.exe"
substring("start regsvr32.exe", 0, 5) // returns "start"
substring("start regsvr32.exe", 6, 14) // returns "regsvr32"
substring("start regsvr32.exe", -4) // returns ".exe"
substring("start regsvr32.exe", -4, -1) // returns ".ex"
----
*Syntax*
[source,txt]
----
substring(<source>, <start_pos>[, <end_pos>])
----
*Parameters*
`<source>`::
(Required, string)
Source string.
`<start_pos>`::
+
--
(Required, integer)
Starting position for extraction.
If this position is higher than the `<end_pos>` position or the length of the
`<source>` string, the function returns an empty string.
Positions are zero-indexed. Negative offsets are supported.
--
`<end_pos>`::
(Optional, integer)
Exclusive end position for extraction. If this position is not provided, the
function returns the remaining string.
+
Positions are zero-indexed. Negative offsets are supported.
*Returns:* string
====