ES|QL REPLACE function
string- String expression.
regex- Regular expression.
newString-
Replacement string.
The function substitutes in the string str any match of the regular expression regex with the replacement string newStr.
| string | regex | newString | result |
|---|---|---|---|
| keyword | keyword | keyword | keyword |
| keyword | keyword | text | keyword |
| keyword | text | keyword | keyword |
| keyword | text | text | keyword |
| text | keyword | keyword | keyword |
| text | keyword | text | keyword |
| text | text | keyword | keyword |
| text | text | text | keyword |
This example replaces any occurrence of the word "World" with the word "Universe":
ROW str = "Hello World"
| EVAL str = REPLACE(str, "World", "Universe")
| str:keyword |
|---|
| Hello Universe |
This example removes all spaces:
ROW str = "Hello World"
| EVAL str = REPLACE(str, "\\\\s+", "")
| str:keyword |
|---|
| HelloWorld |