You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[DOCS-11875] Add regex section to DDSQL reference (#31265)
* [DOCS-11875] Add regex section to DDSQL reference
* Remove use of passive voice
* Update content/en/ddsql_reference/_index.md
Co-authored-by: May Lee <[email protected]>
* Update link list and clarify global flag
---------
Co-authored-by: jinatdatadog <[email protected]>
Co-authored-by: May Lee <[email protected]>
@@ -25,6 +25,7 @@ DDSQL is SQL for Datadog data. It implements several standard SQL operations, su
25
25
This documentation covers the SQL support available and includes:
26
26
-[Syntax compatible with PostgreSQL](#syntax)
27
27
-[SQL functions](#functions)
28
+
-[Regular expressions](#regular-expressions)
28
29
-[Window functions](#window-functions)
29
30
-[JSON functions](#json-functions-and-operators)
30
31
-[Table functions](#table-functions)
@@ -118,9 +119,6 @@ The following SQL functions are supported. For Window function, see the separate
118
119
|`TO_TIMESTAMP(string timestamp, string format)`| timestamp | Converts a string to a timestamp according to the given format. |
119
120
|`TO_CHAR(timestamp t, string format)`| string | Converts a timestamp to a string according to the given format. |
120
121
|`DATE_TRUNC(string unit, timestamp t)`| timestamp | Truncates a timestamp to a specified precision based on the provided unit. |
121
-
|`REGEXP_LIKE(string s, pattern p)`| Boolean | Evaluates whether a string matches a regular expression pattern. |
122
-
|`REGEXP_MATCH(string s, pattern p)`| array of strings | Returns substrings of the first pattern match in the string. |
123
-
|`REGEXP_REPLACE(string s, pattern p, string replacement [, string flags ])`| string | Replaces the first occurrence of the pattern in a string with the replacement. Optional `flags` argument, add `'g'` (global) to match all occurrences instead of first. |
124
122
|`CARDINALITY(array a)`| integer | Returns the number of elements in the array. |
125
123
|`ARRAY_POSITION(array a, typeof_array value)`| integer | Returns the index of the first occurrence of the value found in the array, or null if value is not found. |
126
124
|`STRING_TO_ARRAY(string s, string delimiter)`| array of strings | Splits the given string into an array of strings using the given delimiter. |
@@ -369,28 +367,6 @@ FROM
369
367
events
370
368
{{< /code-block >}}
371
369
372
-
### `REGEXP_LIKE`
373
-
{{< code-block lang="sql" >}}
374
-
SELECT
375
-
*
376
-
FROM
377
-
emails
378
-
WHERE
379
-
REGEXP_LIKE(email_address, '@example\.com$')
380
-
{{< /code-block >}}
381
-
382
-
### `REGEXP_MATCH`
383
-
{{< code-block lang="sql" >}}
384
-
SELECT
385
-
REGEXP_MATCH('abc123xyz', '[0-9]+')
386
-
{{< /code-block >}}
387
-
388
-
### `REGEXP_REPLACE`
389
-
{{< code-block lang="sql" >}}
390
-
SELECT
391
-
REGEXP_REPLACE('2025-07/29', '-', '/')
392
-
{{< /code-block >}}
393
-
394
370
### `CARDINALITY`
395
371
{{< code-block lang="sql" >}}
396
372
SELECT
@@ -438,9 +414,117 @@ FROM
438
414
439
415
{{% /collapse-content %}}
440
416
417
+
## Regular expressions
418
+
419
+
### Flavor
420
+
421
+
All regular expression (regex) functions use the International Components for Unicode (ICU) flavor:
422
+
423
+
-[Metacharacters][5]
424
+
-[Operators][6]
425
+
-[Set Expressions (Character Classes)][7]
426
+
-[Flag Options for in-pattern flags][8]. Refer to the [flags section below](#function-level-flags) for function-level flags.
|`REGEXP_LIKE(string input, string pattern)`| Boolean | Evaluates whether a string matches a regular expression pattern. |
434
+
|`REGEXP_MATCH(string input, string pattern [, string flags ])`| array of strings | Returns substrings of the first pattern match in the string. <br><br> This function searches the input string using the given pattern and returns captured substrings (capture groups) from the first match. If no capture groups are present, returns the full match. |
435
+
|`REGEXP_REPLACE(string input, string pattern, string replacement [, string flags ])`| string | Replaces the substring that is the first match to the pattern, or all such matches if you use the [optional `g` flag](#function-level-flags). |
436
+
|`REGEXP_REPLACE (string input, string pattern, string replacement, integer start, integer N [, string flags ] )`| string | Replaces the substring that is the Nth match to the pattern, or all such matches if `N` is zero, starting from `start`. |
0 commit comments